Wednesday, December 19, 2012

Internet Sharing


Topologi yang akan dipakai:
Internet (ppp0) ==> Ubuntu gateway ==>> Client PC (wlan0)

Configure internal network card

sudo ip addr add 192.168.0.1/24 dev wlan0

Configure NAT

sudo iptables -A FORWARD -o ppp0 -i wlan0 -s 192.168.0.0/24 -m conntrack --ctstate NEW -j ACCEPT
sudo iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -t nat -F POSTROUTING
sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE


Save the iptables

sudo iptables-save | sudo tee /etc/iptables.sav
sudo vim /etc/rc.local 
add the following lines before the "exit 0" line:
iptables-restore < /etc/iptables.sav

Enable routing

sudo vim /etc/sysctl.conf
uncomment:
#net.ipv4.ip_forward=1
sehingga menjadi:
net.ipv4.ip_forward=1


OK, Setting routing selesai. NEXT, membuat hotspot:
1. System setting -> Network -> Wireless
2. use as hotspot
3. option -> connect automatically
4. wireless security to change password

0 comments:

Post a Comment