Im using Ubuntu server edition. In that it's configured to use ip address provided by DHCP. Now, I want to edit the resolv.conf file so that it points to the nameservers that I want to define. Obviously editing the resolv.conf file directly will not work as the changes will get overwritten. I also tried a different approch to edit /etc/resolvconf/resolv.conf.d/head and adding nameserver entries there that worked for me but it is said that it is not recommended. So I want to know how can I add nameserver entries if my machine is configured to use DHCP. I believe I will have to edit /etc/network/interfaces I tried a lot of tricks but nothing seems to work. Also is this possible to add nameserver if using DHCP?
Asked
Active
Viewed 9,387 times
3
Kalle Richter
- 6,180
- 21
- 70
- 103
Tarun
- 4,245
- 13
- 50
- 74
2 Answers
6
You can add new settings in /etc/network/interfaces
It will look like this:
iface eth0 inet static
address x.x.x.x
netmask x.x.x.x
gateway x.x.x.x
dns-nameservers x.x.x.x
Read more from the official documentation
2
On a plain Ubuntu Desktop installation using DHCP you can open the connection editor and change the Method setting on the IPv4 Settings tab to Automatic (DHCP) addresses only. Then add the desired nameserver address in the Additional DNS servers field.
Then edit /etc/NetworkManager/NetworkManager.conf and comment out the line dns=dnsmasq.
jdthood
- 12,467
Paul Reinking
- 21
- 1
dns-nameserversoptions in /etc/network/interfaces. – jdthood Jul 28 '13 at 13:27