Monthly Archives: April 2006

You are browsing the site archives by month.

Internet Connection Sharing (ICS) For Linux

I searched hours at a stretch to find nothing but guides that are outdated or those that are too complex for me. I’m just a linux newbie with just the basics to help me with right? So I just took what I thought was the best mix of a few guides and made my own. In my case I run both Windows XP Professional and Fedora Core 3(Kernel ver’s:: 2.6.9 & 2.6.12) on a dual boot system, which is directly connected to the internet. The other people who share my connection use just windows XP. So this is a Linux to Windows Internet Connection Sharing Guide I guess…

  • You will need two NIC(Network Interface Card)’s in th computer which has direct connection to the internet.
  • Your computer should be running a decent distro of linux like a Fedora, Mandrake or SuSE. Though this guide was specifically written for Fedora Core 3, I think any distro with iptables installed would suffice.
  • Setup up the IP, gateway and DNS’s as usual and save config and restart network. Network setup utility can be found at:: Applications>System Settings>Network. You can check your configuration by doing ifconfig eth0 (assuming eth0 is connected directly connected to the internet).
  • Now set the ip address of you other NIC, eth1, which is connected to your internal network to be:

IP Addr:: 192.168.0.1

Subnet Mask:: 255.255.255.0

  • Now the part of setting up IP configuration for the windows computers of your home network. Their configuration should be:

IP Addr:: 192.168.0.xx

Subnet Mask:: 255.255.255.0

Primary DNS:: same as your primary dns

secondary dns:: same as you secondary dns

Note: xx here is any other number but 1 since your computer has that IP. Also no two computers on you network can have the same IP. xx ranges between 2 and 254.

  • After the network setup has been complete make sure that you are connected to the internet(other windows computers will not get connectivity yet). Make sure you can ping other computers on you network and they can ping you back. Use the command: ping ipaddrofcomputer

Assuming every prerequisite has been completed run the following commands at the CLI(Command Line Interface) :-

Note:: eht0 here is the direct connection to the Internet. You should change the command according to your setup.

/sbin/iptables -F -t nat
/sbin/iptables -A POSTROUTING -t nat -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/service iptables save

Check if your other computers are connected to the internet now, they should be. Restart the computer to make the setup complete.