share internet connection with linux
since i can't afford to use 3G connection at UTM so i'm online through public hotspot at my hostel. even it's not so realiable due to many downtime but it's better then no connection at all right?
my roomate using desktop pc so he have to buy wireless adapter if he want to use the wifi too.
the cheapest wireless adapter will cost around rm 60-70.
since i alway turn my laptop on (it's hot but i don't care) so i told him to find a lan cable for pc to pc connection.
then do a little trick with my ubuntu which is ip masquerading
$sudo iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
eth1 is my wifi card interface, my roomate pc connected to lan network card on eth0
my laptop eth0 setting
ip address : 192.168.1.1
netmask : 255.255.255.0
configured my roomate pc with setting
ip address : 192.168.1.2
netmask : 255.255.255.0
gateway : 192.168.1.1
dns : 161.139.250.2 (utm's dns)
you must put the dns so that you can surf website.
that's it. cheap and easy way to get connected. one meter lan cable will only cost you 90 cent
added : make sure you enabled ip forwarding
$echo 1 > /proc/sys/net/ipv4/ip_forward
or put net.ipv4.ip_forward=1 in your /etc/sysctl.conf if you want it to be permanent
p/s: iptables rule set will disappear after reboot
recommended reference : Internet Connection Sharing Server 2 nic cards

![[color] [color]](http://wan.pengganas.net/smilies/color.gif)
8 Comments