Daily Ubuntu / Linux news and application reviews.


What you need for ICS (Internet Connection Sharing) on Ubuntu:

-2 network cards on the computer the internet is coming from
-1 network cable (not crossover) to connect the two computers
-1 network card on the second computer (obviously)

Then, for the computer the internet is coming from, follow these steps:

1. Open a terminal and type this:
sudo ifconfig ethX ip

where 'ethX' is the network card that is going to be connected to the second computer and 'ip' is your desired server ip address (Usually is used)

2. Then configure the NAT as follows:

sudo iptables -t nat -A POSTROUTING -o ethX -j MASQUERADE

where 'ethX' is the network card that the Internet is coming from, and then:

sudo echo 1 > /proc/sys/net/ipv4/ip_forward

3. Install dnsmasq and ipmasq using apt-get:

sudo apt-get install dnsmasq

4. Restart dnsmasq:
sudo /etc/init.d/dnsmasq restart

5. Repeat steps 1 and 2.

6. Add the line "net.ipv4.ip_forward = 1" to /etc/sysctl.conf

sudo gedit /etc/sysctl.conf

7. Reboot. (Optional)

For the second computer, follow these steps:

Set the network card ip to:
Netmask: like the first computer

You can also enter the internet DNS's from the computer connected to the internet.

(The DNS's can be found in the following file: /etc/resolv.conf and have this syntax: nameserver ip)

Update: for Ubuntu Jaunty and later, you must add a line to /etc/rc.local so that this is persistent after restarting your computer. To do this, press Alt + F2 and enter:
gksu gedit /etc/rc.local

And paste this in the above file:
sudo iptables -A POSTROUTING -t nat -j MASQUERADE

Newer Post
Older Post