Setting up a static ip address is useful for a lot of things, especially if you run a web server for example and don’t want to change the port forwarding rules on your router each time it allocates a different ip to your Ubuntu server.
Only use this guide if you already know the working network configuration (ip, mask, gateway and dns servers).
First of all, open a terminal window and edit the network interfaces file:
sudo nano /etc/network/interfaces
You will find here something like this:
iface eth0 inet dhcp
Edit that file accordingly and replace with your own ip configuration. The dns nameservers are actually Google’s dns servers so if you don’t know your own ISP ones, you can use those:
iface eth0 inet static
dns-nameservers 184.108.40.206 220.127.116.11
Restart the interface:
sudo ifdown eth0 && sudo ifup eth0