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:

#!/bin/sh
sudo ifconfig eth0 192.168.0.1


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 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

0 comments:

Post a Comment