To make your box have a static IP in Ubuntu 12.04 that will never change, it’s quite simple.

Let’s start off pulling up the interfaces with this command :

sudo nano /etc/network/interfaces

Go ahead and delete it, and add this :


auto lo eth0
iface lo inet loopback
iface eth0 inet static
address XXX.XXX.XXX.XXX
netmask XXX.XXX.XXX.XXX
gateway XXX.XXX.XXX.XXX

Make sure that
Address = What you want your IP to be.
Netmask = You’re netmask.
Gateway = You’re router’s IP.

End with a ctrl+x then hit Y to save and an enter.

Next let’s add your name servers. Run this command to edit:

sudo nano /etc/resolv.conf

You will see that it states :
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND — YOUR CHANGES WILL BE OVERWRITTEN

So we have to go edit the static file :

sudo nano /etc/resolvconf/resolv.conf.d/base

Feel free to use these Nameservers as they are from opendns, but make sure you delete everything in the file already (it most likely will be an empty file.


nameserver 208.67.222.222
nameserver 208.67.220.220

End with a ctrl+x then hit Y to save and an enter.

Finally let’s restart all the services so that we know everything is set :

sudo /etc/init.d/networking restart