Tuesday, March 10, 2009

Instant Internet Connection Sharing

Today I came Kandy for 5 days stay due to some functions lined up to attend. My office provided me a HSPA dongle to keep my self online during the stay. Nah.. it's not about the dongle. ;-). I wanted to share the Internet connection with another computer at home. I only had a crossover cable with me, which I always carry in my backpack. So I connected the two Laptops with it and shared my primary PPP connection with the guest Laptop. Both Laptops are runnung on GNU/Linux. The simple setup I had is as below.

Host PC Settings.

I already received an IP for my ppp0 connection from my ISP. So I only had to assign an IP to my LAN card (eth0)

# ifconfig eth0 netmask

(Don't need to set the default route in the host, cos it's already set to ppp0)

Enable NAT in Farewall and IP forwarding.

# iptables -P FORWARD ACCEPT
# iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

# echo 1 > /proc/sys/net/ipv4/ip_forwad

Guest Settings.

Set up the Interface.

# ifconfig eth0 netmask

Set the default route of the GUEST to HOST eth0 IP

# route add default gw

Put the name server IP which received to the HOST PC from ISP in the GUEST /etc/resolv.conf

# echo nameserver xxx.xxx.xxx.xxx > /etc/resolv.conf

That's all. I simply enabled Internet Connection Sharing in my Laptop.

1 comment:

Mundir Razik said...

Thanks for this. Will try it out. Tried to connect to the internet with a dialog dongle on ubuntu and failed miserably.