Ubuntu 14.04+: Changing to Static IP

Whenever you make an Ubuntu Server box, it’s standard to make it a static IP. There are many other pages out there that say different things on how to do this, but most of them miss the whole DNS part of it, or they have you go through extra steps that aren’t necessary anymore.

First, edit /etc/network/interfaces:

sudo vim /etc/network/interfaces

Then change:

iface eth0 inet dhcp


iface eth0 inet static

Then, add the following lines:

address your.ip.address.here
netmask your.netmask.here
gateway your.gateway.here
dns-nameservers your.dns.nameserver.here optional.second.server.here

Here is an example of a completed static entry:


Save and exit.Then run the following to disable DHCP client for next reboot:

sudo update-rc.d -f dhcp3-server remove

Finally, restart the interface (or just reboot):

sudo ifdown eth0
sudo ifup eth0

That’s it! You can test by pinging Google/Yahoo/etc. The command ifconfig will show you the current configuration of network interfaces.