Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,780,205 Members 40,497 Now Online
XDA Developers Android and Mobile Development Forum

Tethering via WiFi - Troubleshooting

Tip us?
 
divinehawk
Old
(Last edited by divinehawk; 10th November 2008 at 06:19 PM.) Reason: add note
#1  
Junior Member - OP
Thanks Meter 1
Posts: 9
Join Date: Nov 2008
Cool Tethering via WiFi - Troubleshooting

FYI,

I've been able to successfully use iptables to configure ip masquerading (NAT). With it, I am tethered over WiFi without using tetherbot (which still works as a backup). Hopefully someone else can package this to be more useful.
Update: See posts #13 and #15 on how to use Ad-hoc mode.
  • Root required
  • Existing wifi network required (and configured)

1> Disable WiFi through the UI. Then turn on Wifi manually using the following commands as root. Normally the phone data interface and WiFi can't be turned on at the same time. (Can this be done through the android gui somehow?)

Quote:
insmod /system/lib/modules/wlan.ko

wlan_loader -f /system/etc/wifi/Fw1251r1c.bin -e /proc/calibration -i /system/etc/wifi/tiwlan.ini

cd /data/local/tmp
wpa_supplicant -f -Dtiwlan0 -itiwlan0 -c/data/misc/wifi/wpa_supplicant.conf &

sleep 5
ifconfig tiwlan0 192.168.2.30 netmask 255.255.255.0
ifconfig tiwlan0 up
Note that I had to use a static ip since dhcp will typically add in a gateway.

2> Enable and configure ip forwarding

Quote:
iptables -I FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -I FORWARD -s 192.168.2.0/24 -j ACCEPT
iptables -P FORWARD DROP

iptables -t nat -I POSTROUTING -s 192.168.2.0/24 -j MASQUERADE

echo 1 > /proc/sys/net/ipv4/ip_forward
3> On your computers, set your default gateway to your phone's WiFi IP address (192.168.2.30 - in my case). Also set your DNS to a real DNS server.

Attached is the iptables binary, compiled with the android sdk.
Attached Files
File Type: zip iptables.zip - [Click for QR Code] (54.8 KB, 2127 views)
The Following User Says Thank You to divinehawk For This Useful Post: [ Click to Expand ]
 
hondamx525
Old
#2  
Senior Member
Thanks Meter 0
Posts: 303
Join Date: Oct 2008
just curious as to why you would want the "tethering" this way. isnt it most likely that any wifi your phone can connect to your computer most probably can too? just curious?
 
neoobs
Old
#3  
Retired Moderator
Thanks Meter 10
Posts: 1,271
Join Date: Mar 2008
Quote:
Originally Posted by hondamx525 View Post
just curious as to why you would want the "tethering" this way. isnt it most likely that any wifi your phone can connect to your computer most probably can too? just curious?
This is just progress on tethering. The proxy method is a horrible way of tethering. iptables is the correct way if done correctly. His developments while useless to most are still good because it is progressive. And he can get hotspots now LOL
 
divinehawk
Old
#4  
Junior Member - OP
Thanks Meter 1
Posts: 9
Join Date: Nov 2008
Quote:
Originally Posted by hondamx525 View Post
just curious as to why you would want the "tethering" this way. isnt it most likely that any wifi your phone can connect to your computer most probably can too? just curious?
The above configuration uses your existing wifi settings (I haven't tried ad-hoc mode).

USB networking would be better, or even bluetooth. But I'm not sure this is possible.
 
add3421
Old
#5  
Senior Member
Thanks Meter 34
Posts: 1,385
Join Date: Mar 2007
Location: Wilmington!
wmwifi router is such an amasing program for windows mobile. Not only does it create an access point with encryption, it also has a dhcp server set up, so multiple computers can share the 3G access. If something like this comes to the android, it will be BADASS!


Nexus 4

Galaxy Nexus

HTC Doubleshot A.K.A. T-Mobile TouchMe

T-Mobile G2

Samsung Vibrant - POS

Nexus One

HTC Dream G1

T-Mobile Wing

T-Mobile Dash
 
scootley
Old
#6  
Junior Member
Thanks Meter 5
Posts: 29
Join Date: Nov 2008
divinehawk, do you really need an access point? have you tried this using an ad-hoc network? (I am not sure if the G1's WiFi supports ad-hoc networks)
 
divinehawk
Old
#7  
Junior Member - OP
Thanks Meter 1
Posts: 9
Join Date: Nov 2008
Quote:
Originally Posted by scootley View Post
divinehawk, do you really need an access point? have you tried this using an ad-hoc network? (I am not sure if the G1's WiFi supports ad-hoc networks)
Doesn't look like the gui will let you do ad-hoc. Maybe if a modified wpa_supplicant.conf. I'll report back if I have success.

Ideal mode would be for the phone to *act* as an access point. But that usually requires driver support.
 
alansj
Old
(Last edited by alansj; 10th November 2008 at 06:58 AM.)
#8  
Member
Thanks Meter 29
Posts: 44
Join Date: Nov 2008
Quote:
Originally Posted by divinehawk View Post
USB networking would be better, or even bluetooth. But I'm not sure this is possible.
Code:
# adb --help
[...]
adb forward <local> <remote> - forward socket connections
                                 forward specs are one of: 
                                   tcp:<port>
[...]
...but I guess everybody already knew that. I suppose that doing it via iptables under this approach, you are still limited to specific ports.
 
neoobs
Old
#9  
Retired Moderator
Thanks Meter 10
Posts: 1,271
Join Date: Mar 2008
Quote:
Originally Posted by alansj View Post
Code:
# adb --help
[...]
adb forward <local> <remote> - forward socket connections
                                 forward specs are one of: 
                                   tcp:<port>
[...]
that only works if you want to make a proxy... I think he is trying to make it a true internet sharing app similar to that of the wing and other WM devices
 
alansj
Old
#10  
Member
Thanks Meter 29
Posts: 44
Join Date: Nov 2008
How about something similar to PdaNet?

http://www.theiphoneblog.com/2008/10...r-with-pdanet/

It's interesting that it works by having you set up an ad-hoc wireless network from your computer and then connecting to that from the iPhone. Maybe that's essentially what scootley was suggesting above.

PdaNet .deb here:
http://apt.modmyi.com/2debs/pdanet1.40.deb

Tags
ad-hoc, tether
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes