User:Jebba/NAT

Contents

[edit] NAT

This is a micro HOWTO, perhaps someday to be longer about how to turn your N900 into a wifi hotspot. In other words, you connect to the Internet via the GPRS (telephone data) connection, then share your connection via wifi with everyone within reach.  :)


[edit] kernel

You will need a kernel with NAT modules. I have one available. See my installing my custom kernel to get a usable kernel if you don't feel like building one. The 2.6.28-omap1-jebba6 kernel is known to work (2.6.28-20094102.3+0m11).


[edit] iptables / iwconfig

You need iptables and iwconfig to use this script. Thankfully they are in the extras-devel repository:

apt-get install iptables wireless-tools


[edit] freemoe-nat

Create and run this script:

#!/bin/sh
# Run this script to share your Internet connection.
# Activate your gprs0 (fone data) connection with the GUI
# Then run this  :)

set -x

# insert masquerade module
sudo modprobe ipt_MASQUERADE

# flush old rules
sudo iptables -F
sudo iptables -t nat -F

sudo iptables -t nat -A POSTROUTING -o gprs0 -j MASQUERADE

# forward IPs
echo -n 1 | sudo tee /proc/sys/net/ipv4/ip_forward

sudo ifconfig wlan0 down
sudo iwconfig wlan0 mode ad-hoc
sudo ifconfig wlan0 up
sudo iwconfig wlan0 essid freemoe
sudo ifconfig wlan0 10.0.0.1 netmask 255.255.255.0 up


[edit] Set up Guests

Right now the above doesn't provide DHCP or DNS services, which means you have to set up a static IP and set up DNS in your clients. Just use a static IP from 10.0.0.2 to 10.0.0.254, use 8.8.8.8 for your DNS servers, and set your gateway to 10.0.0.1. You'll need to set your client in ad-hoc mode and use ESSID freemoe.