10

Currently my /etc/resolv.conf reads:

nameserver 127.0.0.1  
nameserver 10.255.0.101  
nameserver 10.255.0.11  

and I want it to instead read:

search [my domain]  
nameserver 10.255.0.101  
nameserver 10.255.0.11  
nameserver 208.67.222.222  
nameserver 208.67.220.220  

As both /etc/resolv.conf and /etc/resolv.conf.d/head can't be edited by hand, how can I make this change?

7

First, /etc/resolvconf/resolv.conf.d/head can be edited by hand. The comment in the file which says DO NOT EDIT THIS FILE BY HAND does not apply to /etc/resolvconf/resolv.conf.d/head itself but to /etc/resolv.conf, to which the former is prepended.

Having said that, however, under normal circumstances you should not have to edit /etc/resolvconf/resolv.conf.d/head.

The files /etc/resolvconf/resolv.conf.d/head and /etc/resolvconf/resolv.conf.d/tail are provided as a way of forcing a head and tail onto the generated resolv.conf should that be needed under exceptional circumstances, but if you are using resolvconf properly and under normal circumstances then you do not have to do this.

You say that the file content is

nameserver 127.0.0.1
nameserver 10.255.0.101
nameserver 10.255.0.11

The presence of the line nameserver 127.0.0.1 suggests that you are running a local forwarding nameserver such as dnsmasq. The file above is not what resolvconf normally generates under these circumstances. It normally generates a file like the following.

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.0.1
search foo.com

My guess is that on your system /etc/resolv.conf is not a symbolic link to ../run/resolvconf/resolv.conf but is a plain file which may or may not be generated by something other than resolvconf. If the file is completely static then simply edit it so that it looks the way you want it to look. If the file is generated by some tool other than resolvconf then figure out what tool is generating the file and configure that tool.

Alternatively, restore the symbolic link /etc/resolv.conf -> ../run/resolvconf/resolv.conf and configure resolvconf properly.

How do I remove localhost nameserver from resolv.conf?

The following instructions apply only to the case where you are using resolvconf to manage /etc/resolv.conf, i.e., /etc/resolv.conf is a symbolic link to ../run/resolvconf/resolv.conf.

If the line nameserver 127.0.0.1 is in one of the files in /etc/resolvconf/resolv.conf.d/ then remove it from there.

Otherwise that line is coming from some locally running nameserver. Either de-install that nameserver or configure that nameserver not to register the address 127.0.0.1 with resolvconf. In particular, if you are running BIND 9 named locally, either remove it or set RESOLVCONF=no in /etc/default/bind9.

Ref: https://bugs.launchpad.net/debian/+source/bind9/+bug/933723

| improve this answer | |
2

Try

sudo vi /run/resolvconf/interface/NetworkManager

Remove or replace nameserver 127.0.0.1, then use

sudo resolvconf -u.
| improve this answer | |
1

Check your NetworkManager configuration:

sudo NetworkManager --print-config

if there's

dns=systemd-resolved

then edit settings in

/run/resolvconf/interface/systemd-resolved

and update

sudo resolvconf -u

In my case there was also

/run/resolvconf/interface/tun0.openvpn

file (created by OpenVPN) which can be safely deleted to avoid interference:

sudo rm /run/resolvconf/interface/tun0.openvpn
| improve this answer | |

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.