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

8 Comments

  1. Posted January 7, 2008 at 4:51 pm | Permalink

    Owh owh owh… Kalu XP, just dharing connection jer kan…..

  2. Posted January 7, 2008 at 5:27 pm | Permalink

    laju tak internet ? berapa downstream/ upstream ?

  3. azraai
    Posted January 7, 2008 at 5:29 pm | Permalink

    wei ko tahu apa masalah besar ngan linux. semua yg di intergrate dalam windows melalui GUI kena guna terminal kat linux.

    org dari era 80an tau la guna terminal. lahir tahun 91 mampus lu nak guna skrin hitam putih.

    aku tau mkdir jer dalam terminal tu.

  4. Posted January 7, 2008 at 5:31 pm | Permalink

    Adakah bermaksud kawan kau itu boleh masuk PC kau? Hu3. Saje je nak tanya kan…

  5. Posted January 7, 2008 at 11:43 pm | Permalink

    @azhar a’ah..tick je share connection kekeke

    @adi ibarat guna streamyx pakej 1mb kat cc tapi biasala bila wifi ni putus2 je selalu

    @azraai ada yang lahir tahun 1995 yg geti cmdline,selalu guna nanti mahir la..lolz

    @fauzi bleh..kat shared folder je :D

  6. azraai
    Posted January 8, 2008 at 10:28 pm | Permalink

    linux, windows, dgn apple punya command line beza. windows punya command prompt aku dah hafal command dia. tapi linux jer tak hafal sbb mmg lahir dah lama.

  7. Posted January 10, 2008 at 2:24 am | Permalink

    Command tuk epel ape? hahaha

    (saya baru belajar)

  8. ptra8
    Posted January 26, 2008 at 12:54 am | Permalink

    ubuntu user :[color]

    http://ubuntuforums.org/showthread.php?t=335465