Setting a Permenant IP Address in UBuntu

To permanently set up the ip and gateway, you have to edit
/etc/network/interfaces. It is advisable if you backup the existing
interfaces file, if it is available.

1. Backup
/etc/network/interfaces
$ sudo
cp /etc/network/interfaces /etc/network/interfaces.bak

2.
Open the /etc/network/interfaces using your favorite text editor
$ sudo vi /etc/network/interfaces

3.
Add the below setting to add ip, netmask and gateway

# The loopback interface
auto lo
iface lo inet loopback

# The first network card – this entry
was created during the Debian installation

# (network, broadcast and gateway are optional)
auto eth0
iface eth0 inet static
#set your static IP
below

address
10.20.1.10

#set your
default gateway IP here

gateway
10.20.1.1

# set your
netmask, network and broadcast ip below

netmask 255.255.255.0
network 10.20.1.0
broadcast 10.20.1.255

4. Save your
configuration and restart network
$ sudo /etc/init.d/network restart

5. Your
debian/ubuntu server machine is now operating with the new ip. Check ip
and gateway using ifconfig
and route -n