How to add a static IP in Ubuntu

To add static IP address to your server first you need to log into your server with root privileges. By default Ubuntu server sets the interface to use DHCP. To assign a static IP you need to edit:


# /etc/network/interfaces


Here you will find here something like this:

auto eth0

iface eth0 inet dhcp


Edit that file accordingly and replace with your own IP configuration. (If you don’t know your own ISP’s DNS servers you can use Google’s DNS):

auto eth0

iface eth0 inet static






Save and exit:



Reload (start and stop) network:

# sudo ifdown eth0 && sudo ifup eth0