android 手機通過 usb 共享電腦網絡

此文版權屬於作者所有,任何人、媒體或者網站轉載、借用都必須徵得作者本人同意!

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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章