3

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?

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

  • 1
    Just to clarify, the key here is the: iface eth0 inet static – Atari911 Jul 26 '13 at 15:25
  • Thanks for the reply all. @Atari911: mine configuration is not static its like auto lo iface lo inet loopback dns-nameservers x.x.x.x. To use the dns server I will have to configure static ip address??? – Tarun Jul 27 '13 at 5:39
  • @Tarun: If your interface is configured dynamically, i.e., via DHCP, then normally you don't have to enter any nameserver information manually because that information is received via DHCP. If your circumstances are exceptional then please describe those circumstances in your question. If you are using NetworkManager then you should enter nameserver information into the connection editor (e.g., in the Edit Connections | Edit... | IPv4 Settings | Additional DNS servers field) and not include any dns-nameservers options in /etc/network/interfaces. – jdthood Jul 28 '13 at 13:27
  • Ya. Mine is configured to use DHCP. But how can I edit it to use the nameserver because I'm using cli mode I dont have a gnome on it. – Tarun Jul 29 '13 at 6:22
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.