How to Set a Static IP and DNS in Ubuntu 14.04

Post by on May 17, 2014

Ubuntu 14.04 no longer allows you to edit /etc/resolv.conf directly. Instead, you have to modify /etc/resolvconf/resolv.conf.d/head or tail. The way it works is /etc/resolv.conf is written from:

  1. /etc/resolvconf/resolv.conf.d/head
  2. any dns set on interfaces
  3. /etc/resolvconf/resolv.conf.d/base
  4. /etc/resolvconf/resolv.conf.d/tail

So, you can edit /etc/resolvconf/resolv.conf.d/head or base or tail, but it will be easiest to set this along side your ethernet config, in my opinion.

To set a static IP edit /etc/network/interfaces and change the following:

auto eth0
iface eth0 inet dhcp


auto eth0
  iface eth0 inet static

Obviously, you will want to change eth0 to whatever your network card is called (hint: ifconfig) and change your dns-nameservers to whatever you want them to be. Now, if you want your DNS to come from your ISP then don't set any and it will work fine.

Finally, restart your ethernet:

$ service networking restart
$ ifdown eth1
$ ifup eth1

Now, I'm not 100% sure all three commands are needed. But, I know that the above ensured that /etc/resolv.conf was re-written and the IP was taken.

Older Posts »