This is my first howto so please bear with me.
The reason that I am writing this:
I was migrating servers to a new setup. Before I just had a desktop and I installed a LAMP and ran with it. Later I got actual server hardware and installed the server edition of ubuntu. I had the new server set on DHCP for the migration and after the migration I needed to change the IP from DHCP to STATIC and that way all my DNS stuff would just be done. The thing is I didn't have a GUI and I had to do it via command line.
So here it goes.
First, edit /etc/network/interfaces.
Change the entry for your ethernet device (eth0 in my case) so line that instead of this:
change it so that it says this:
iface eth0 inet dhcp
Then just restart the networking daemon
iface eth0 inet static
address <ip address of your choice>
netmask <netmask, usually 255.255.255.0>
broadcast <broadcast ip>
gateway <ip of gateway>
After the restart it should have the static IP that you set.
sudo /etc/init.d/networking restart
This will of course work for any machine. But is particularly convenient for a server where you are ssh'd in.
If you are having DNS issues after that edit your /etc/resolv.conf and add the line
The order of the nameservers entered are the order that the system will use to try a DNS lookup. Usually two are sufficient. I do mine as first nameserver the internal DNS, second I do a public DNS and I use 220.127.116.11 . You could also use openDNS which is 18.104.22.168 and 22.214.171.124 . Either one should do it for you.