Linux

How do i setup a static IP address – Ubuntu 11.10

If your Ubuntu 11.10 server, has a DHCP assigned IP address and you want to allocate a static IP address you will need to do the following:

edit the file /etc/network/interfaces

sudo vi /etc/network/interfaces

You will notice the following lines:

auto eth0
iface eth0 inet dhcp

This needs to be changed to:

auto eth0
iface eth0 inet static
address xxx.xxx.xxx.xxx
netmask yyy.yyy.yyy.yyy
network zzz.zzz.zzz.zzz
broadcast aaa.aaa.aaa.aaa
gateway bbb.bbb.bbb.bbb

Where:

  • xxx.xxx.xxx.xxx is the static IP address you want to allocate.
  • yyy.yyy.yyy.yyy is the netmask for the network the IP address is in. In a typical class C network this is 255.255.255.0
  • zzz.zzz.zzz.zzz is the network that the IP address is located in. In a typical class C network this would be xxx.xxx.xxx.0 (xxx.xxx.xxx is the first three octets from above)
  • aaa.aaa.aaa.aaa is the broadcast address for the network. In a typical class C network the this would be xxx.xxx.xxx.255 (xxx.xxx.xxx is the first three octets from above).
  • bbb.bbb.bbb.bbb is the default gateway for the network the IP address is located in.

After the change has been made you will need to restart the network service, this is best done on the console, if the following is completed over a remote session (ssh for example) your session will terminate and if a mistake has been introduced you may not be able to get access again.

sudo service network restart

 By Jay Fearn Google