Go Back   xda-developers > HTC Dream: G1 > G1 Android Development


Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10th November 2008, 04:18 AM
divinehawk divinehawk is offline
Junior Member
 
Join Date: Nov 2008
Posts: 9
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 (54.8 KB, 679 views)

Last edited by divinehawk; 10th November 2008 at 07:19 PM.. Reason: add note
Reply With Quote
Sponsored Links

  #2  
Old 10th November 2008, 04:20 AM
hondamx525 hondamx525 is offline
Senior Member
 
Join Date: Oct 2008
Posts: 285
Default

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?
Reply With Quote

  #3  
Old 10th November 2008, 04:31 AM
neoobs neoobs is offline
Moderator
 
Join Date: Mar 2008
Posts: 1,235
Default

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
Reply With Quote

  #4  
Old 10th November 2008, 04:42 AM
divinehawk divinehawk is offline
Junior Member
 
Join Date: Nov 2008
Posts: 9
Default

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.
Reply With Quote

  #5  
Old 10th November 2008, 04:44 AM
aad4321 aad4321 is offline
Senior Member
 
Join Date: Mar 2007
Location: Wilmington!
Posts: 930
Default

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 One - Cyanogen Follower

HTC Dream - Cyanogen Follower

T-Mobile Wing
Reply With Quote

  #6  
Old 10th November 2008, 04:59 AM
scootley scootley is offline
Junior Member
 
Join Date: Nov 2008
Posts: 7
Default

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)
Reply With Quote

  #7  
Old 10th November 2008, 05:22 AM
divinehawk divinehawk is offline
Junior Member
 
Join Date: Nov 2008
Posts: 9
Default

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.
Reply With Quote

  #8  
Old 10th November 2008, 07:50 AM
alansj alansj is offline
Member
 
Join Date: Nov 2008
Posts: 41
Default

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.

Last edited by alansj; 10th November 2008 at 07:58 AM..
Reply With Quote

  #9  
Old 10th November 2008, 07:52 AM
neoobs neoobs is offline
Moderator
 
Join Date: Mar 2008
Posts: 1,235
Default

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
Reply With Quote

  #10  
Old 10th November 2008, 08:40 AM
alansj alansj is offline
Member
 
Join Date: Nov 2008
Posts: 41
Default

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
Reply With Quote

Reply

Tags
ad-hoc, tether

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:06 AM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.