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

来源:互联网 发布:网络用语2017最新数字 编辑:程序博客网 时间:2024/06/11 20:44

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

参考: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"


0 0