ICS Ubuntu, Simplified.

We have a good WiFi enabled Internet campus. Unfortunately, one of the Ubuntu Lucid installations in a Dell Inspiron did not detect the WiFi controller. The last resort was to get an ethernet cable with Internet connection to activate the driver. We asked google and found out perhaps the best solutions to do ICS (Internet Connection Sharing) with Ubuntu here.

I would brief the steps taken so that anybody can get this done very quickly.

Our situation is different from that described in the above document.

Server connected to Internet via wlan0.

Client connected to server via eth0.

You have to make sure no changes to networking has been done since turning on both the computers. If any, you would have to restart both of them.

Server side configuration.

  • Connect the computer to wlan0 and make sure the Internet access is available.

Start a terminal and do the following to configure your network card and NAT.

  • sudo ifconfig eth0 192.168.0.1
  • sudo iptables -A FORWARD -i wlan0 -o eth0 -s 192.168.0.0/24 -m conntrack –ctstate NEW -j ACCEPT
  • sudo iptables -A FORWARD -m conntrack –ctstate ESTABLISHED,RELATED -j ACCEPT
  • sudo iptables -A POSTROUTING -t nat -j MASQUERADE

These settings will be cleared when you reboot the system. If you want to set it up permanently then:

  • sudo iptables-save | sudo tee /etc/iptables.sav

Edit /etc/rc.local and add the following lines before the “exit 0” line:

  • iptables-restore < /etc/iptables.sav

Enable routing:

  • sudo sh -c “echo 1 > /proc/sys/net/ipv4/ip_forward”

Edit /etc/sysctl.conf and add these lines:

  • net.ipv4.conf.default.forwarding=1
  • net.ipv4.conf.all.forwarding=1

Client setup:

Disable networking

  • sudo /etc/init.d/networking stop

Give static IP address.

  • sudo ifconfig eth0 192.168.0.100

Configure routing.

  • sudo route add default gw 192.168.0.1

Configure DNS Servers.

  • Open /etc/resolv.conf in the server and add the contents to resolv.conf of the client.

Open /etc/dhcp3/dhclient.conf and add:

  • prepend domain-name-servers 208.67.222.222,208.67.220.220;

Restart Networking:

  • sudo /etc/init.d/networking restart

You are good to go!

Note: If you are in a proxy network make sure to apply the proxy settings to the client also.

Leave a Reply

Your email address will not be published. Required fields are marked *