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?
You can add new settings in
/etc/network/interfaces
It will look like this:
Read more from the official documentation
On a plain Ubuntu Desktop installation using DHCP you can open the connection editor and change the
Method
setting on theIPv4 Settings
tab toAutomatic (DHCP) addresses only
. Then add the desired nameserver address in theAdditional DNS servers
field.Then edit /etc/NetworkManager/NetworkManager.conf and comment out the line
dns=dnsmasq
.