Difference between revisions of "NAT Gateway by iptables dnsmasq"

From WebOS Internals
Jump to navigation Jump to search
(Added info how to tether USB to Wi-Fi)
Line 2: Line 2:
  
 
https://help.ubuntu.com/community/Internet/ConnectionSharing
 
https://help.ubuntu.com/community/Internet/ConnectionSharing
 
==Shut of the Wifi connection on palm==
 
You will need to shut off wifi on your phone (it won't work otherwise). To do this tap on the upper left hand corner where the wifi icon is. Select "Wi-Fi" -> Turn off Wi-Fi
 
  
 
==Turn on USBnet on palm==
 
==Turn on USBnet on palm==
Line 23: Line 20:
 
</nowiki></pre>
 
</nowiki></pre>
  
==Setup packet forwarding==
+
==Setup packet forwarding to tether usb0 (cable) to ppp0 (EVDO)==
 +
You will need to shut off wifi on your phone (it won't work otherwise). To do this tap on the upper left hand corner where the wifi icon is. Select "Wi-Fi" -> Turn off Wi-Fi
 +
 
 
<pre><nowiki>
 
<pre><nowiki>
 
ifconfig usb0 up
 
ifconfig usb0 up
Line 34: Line 33:
 
iptables -A FORWARD -i ppp0 -d 192.168.2.2 -p tcp --dport 3074 -j ACCEPT
 
iptables -A FORWARD -i ppp0 -d 192.168.2.2 -p tcp --dport 3074 -j ACCEPT
 
iptables -A FORWARD -i ppp0 -d 192.168.2.2 -p udp -m multiport --dports 88,3074 -j ACCEPT
 
iptables -A FORWARD -i ppp0 -d 192.168.2.2 -p udp -m multiport --dports 88,3074 -j ACCEPT
 +
</nowiki></pre>
 +
 +
==Setup packet forwarding to tether usb0 (cable) to eth0 (Wi-Fi)==
 +
Make sure your Wi-Fi is on and connected to an Access Point.
 +
 +
<pre><nowiki>
 +
ifconfig usb0 up
 +
ifconfig usb0 192.168.2.1
 +
sysctl -w net.ipv4.conf.default.forwarding=1
 +
sysctl -w net.ipv4.conf.all.forwarding=1
 +
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.2.0/24 -j MASQUERADE
 +
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 3074 -j DNAT --to-destination 192.168.2.2
 +
iptables -t nat -A PREROUTING -i eth0 -p udp -m multiport --dports 88,3074 -j DNAT --to-destination 192.168.2.2
 +
iptables -A FORWARD -i eth0 -d 192.168.2.2 -p tcp --dport 3074 -j ACCEPT
 +
iptables -A FORWARD -i eth0 -d 192.168.2.2 -p udp -m multiport --dports 88,3074 -j ACCEPT
 
</nowiki></pre>
 
</nowiki></pre>
  

Revision as of 00:29, 4 January 2011

The following guide can be followed on the palm to make a NAT gateway from a usb0 (tether) to ppp0 (EVDO). It is also possible this can be adapted to use a palm pre as a usb wireless adapter, that is NAT gateway from usb0 to eth0. Since wpa_supplicant and wireless tools are included with webos it is also possible that these could be adapted to build your own wifi hotspot from built in commands.

https://help.ubuntu.com/community/Internet/ConnectionSharing

Turn on USBnet on palm

get a root terminal and enter the commands: This requires a reboot so exit anything you're doing on your phone.

usbnet enable
reboot

Make dhcp/dns availalbe to usb0 (only do once)

get root terminal and use the following to make dhcp/dns available to usb0

mount -o remount,rw /
echo interface=usb0 >> /etc/dnsmasq.palm.conf
echo dhcp-range=192.168.2.2,192.168.2.3,2h >> /etc/dnsmasq.palm.conf
stop dnsmasq
start dnsmasq
mount -o remount,ro /

Setup packet forwarding to tether usb0 (cable) to ppp0 (EVDO)

You will need to shut off wifi on your phone (it won't work otherwise). To do this tap on the upper left hand corner where the wifi icon is. Select "Wi-Fi" -> Turn off Wi-Fi

ifconfig usb0 up
ifconfig usb0 192.168.2.1
sysctl -w net.ipv4.conf.default.forwarding=1
sysctl -w net.ipv4.conf.all.forwarding=1
iptables -t nat -A POSTROUTING -o ppp0 -s 192.168.2.0/24 -j MASQUERADE
iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 3074 -j DNAT --to-destination 192.168.2.2
iptables -t nat -A PREROUTING -i ppp0 -p udp -m multiport --dports 88,3074 -j DNAT --to-destination 192.168.2.2
iptables -A FORWARD -i ppp0 -d 192.168.2.2 -p tcp --dport 3074 -j ACCEPT
iptables -A FORWARD -i ppp0 -d 192.168.2.2 -p udp -m multiport --dports 88,3074 -j ACCEPT

Setup packet forwarding to tether usb0 (cable) to eth0 (Wi-Fi)

Make sure your Wi-Fi is on and connected to an Access Point.

ifconfig usb0 up
ifconfig usb0 192.168.2.1
sysctl -w net.ipv4.conf.default.forwarding=1
sysctl -w net.ipv4.conf.all.forwarding=1
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.2.0/24 -j MASQUERADE
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 3074 -j DNAT --to-destination 192.168.2.2
iptables -t nat -A PREROUTING -i eth0 -p udp -m multiport --dports 88,3074 -j DNAT --to-destination 192.168.2.2
iptables -A FORWARD -i eth0 -d 192.168.2.2 -p tcp --dport 3074 -j ACCEPT
iptables -A FORWARD -i eth0 -d 192.168.2.2 -p udp -m multiport --dports 88,3074 -j ACCEPT

Setup your computer

On Ubuntu Linux 10.04 in network manager right click the icon select "Edit Connections". Find the wired interface probably named "Auto usb" edit and uncheck "connect automatically" box.

Windows / Mac instructions coming soon.

Trouble Shooting

Make sure both these values are 1.

sysctl net.ipv4.conf.default.forwarding net.ipv4.conf.all.forwarding

Beware, the palms seems to like setting this to 0 whenever network settings are changed.

References