http://thesimplesynthesis.com/post/how-to-set-a-static-ip-and-dns-in-ubuntu-14-04
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:
- /etc/resolvconf/resolv.conf.d/head
- any dns set on interfaces
- /etc/resolvconf/resolv.conf.d/base
- /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
to:
auto eth0
iface eth0 inet static
address 192.168.0.150
netmask 255.255.255.0
gateway 192.168.0.1
network 192.168.0.0
broadcast 192.168.0.255
dns-nameservers 8.8.8.8 8.8.4.4
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
No Comments