Home Download Ubuntu

Configure start-up script to configure network (ICS, setting up NIC, etc)

Setting up a network interface and ICS are easy tasks. But as an alternative you can do it without modifying those config files, by running some start-up scripts.

1.Let's say we want to set up a network interface, we would have:

Make a start-up script:
sudo nano /etc/init.d/startup

We paste this:

sudo ifconfig eth0

We make it executable:

sudo chmod +x /etc/init.d/startup

Now we add it to system start-up:

sudo update-rc.d startup defaults

Now, every time your system boots Ubuntu, you would have your network interface configured automatically.

2.It's quite the same with ICS (Internet connection sharing):

Assuming that your eth0 nic is the local area network and eth1 is the wide area network (internet), we add this lines in our "/etc/init.d/startup" file made above:

sudo iptables -A FORWARD -i eth1 -o eth0 -s -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


Post a Comment