Sunday, May 28, 2017

wi fi - How to share Android "Reverse-tethered" internet via Android WiFi?


Before going into main question, we do know that :



Now the question is :


"Is there a way to share the reverse-tethered internet (as we known connected via usb0 interface) via "Android WiFi Hotspot?"


To make it easier, here's the schema:


schema
Schema of my setup (click image for larger variant)



*Additional Notes :




  • Actually I don't give a limit which version of the Android (so if it's just compatible in higher version e.g. 4.2, it's okay for me), but I prefer it works on 2.3.x (Gingerbread)




  • Some explanations of how to make APN (Infrastructure Mode) on Android (just like Wireless Router/[netsh wlan hostednetwork] on Windows 7/8) might be really helpful too.



  • And also some explanations about how to masquerade (internet sharing) between two interfaces in Android. (such as ICS in Windows or Masquerade/iptables thingy in Linux-based)




Answer



I managed to make it work. Here is an "OSI-like" diagram of my setup, if it makes sense:


 ____________________   ______________________________    ____________
| LinuxVM <----+ | | | | |
| VirtualBox | | | | | |
| Windows7(host) | | | +--> AndroidPhone <-------+ | | +-->Laptop |
| (USB) +-------+ (USB) (wifi-HotSpot) +-------+ (wifi) |
|___________________| |______________________________| |____________|

The script is located at the XDA forum: http://forum.xda-developers.com/showpost.php?p=50236807&postcount=9



## 0.a. Connect android-phone to PC through USB.
## 0.b Enable Settings|...|Tethering
## (so that the device gets detected by the PC's kernel, you should see the following with 'dmsg':
## [ 3.976599] rndis_host 1-1:1.0 usb0: register 'rndis_host' at usb-0000:00:0b.0-1, RNDIS device, 4e:d5:8c:7b:4f:5a
## Enable Settings|...|Wifi-Hotspot


## Setup usb reverse-tethering.
# from: http://forum.xda-developers.com/show....php?t=2287494
#

# Yours device might be 'rndis0' or something else. Check by just typing 'netcfg'.
#
netcfg usb0 dhcp
busybox route add default gw 10.42.0.1 dev usb0


## Disable mobile-data.
#
busybox ifconfig rmnet_usb0 0.0.0.0



## Masquerade through USB.
#
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -F
iptables -t nat -A POSTROUTING -o usb0 -j MASQUERADE
iptables -P FORWARD ACCEPT


## Set DNS (if neccessary, ie google's 8.8.4.4).

#
setprop net.dns1 XX.YY.ZZ.WW

No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...