您的位置:首页 > 理论基础 > 计算机网络

android 手机通过 usb 共享电脑网络

2017-03-15 16:04 936 查看
此文版权属于作者

所有,任何人、媒体或者网站转载、借用都必须征得作者本人同意!

参考:How to set up reverse tethering over USB?

1、Connect Android device via USB.

2、Enable USB tethering. To do so, go to

 Settings → More... → Tethering & mobile hotspot → Usb tethering.

3、At host machine, the usb tethering connection may be detected by the network manager.

Its name will be something like "Wired connection 2" (or 3).

You must edit it's "IPV4/Method" to "Shared to other computers".

3.1、Without the network manager, you will have to do it manually:

$ sudo ifconfig usb0 10.42.0.1 netmask 255.255.255.0 
$ echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
3.2、modify iptables with

$ sudo iptables -t nat -A POSTROUTING -j MASQUERADE
4、At Android device

$ adb shell su -c "ifconfig rndis0 10.42.0.2 netmask 255.255.255.0"
$ adb shell su -c "route add default gw 10.42.0.1 dev rndis0"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android usb reverse