Static DNS servers not in resolv.conf [Solved]

Issues Related to Networking (Wired and Wireless)

Moderator: Moderators

Static DNS servers not in resolv.conf [Solved]

Postby twhite » Wed Sep 21, 2016 16:23

I'm trying to set up static DNS servers under systemd, NetworkManager, and resolvconf. I've added the following line to /etc/dhcp/dhcpd.conf. I've tried different formats without success.

Code: Select all
prepend domain-name-servers,,;

When I trigger re-reading the connection information (re-connect the wifi,
systemctl restart NetworkManager
, or
resolvconf -u
) the DNS server information is re-written. It also rewrites /etc/resolvconf/run/resolv.conf which is pointed to by /etc/resolv.conf. However it only includes the and not the other two. is used to first try to get the cached IP from dnsmasq.

I can see that it updates the resolvconf database with all three DNS servers by using
nmcli dev show
resolvconf -l
but it doesn't pass that on to resolv.conf. I can edit the /etc/resolv.conf and add the other 2 nameservers and everything works fine until it's reset with a boot or re-connection.

Since the wifi seems to drop often (separate problem) it's a real pain to edit all the time. My system is updated as of a couple days ago. I can work around it but prefer to fix it within the existing system. I haven't been able to find this specific problem anywhere. Can you please help or point me to some documentation on this.
Last edited by twhite on Thu Sep 22, 2016 14:32, edited 1 time in total.
Baby Hen
Posts: 7
Joined: Tue Sep 20, 2016 20:57

Re: Static IPs in dhcpd.conf not written to resolv.conf

Postby albfneto » Wed Sep 21, 2016 17:39

in my laboratory at the University (my Job), i also have Static IP, Static DNS and Static Gateway.
For my Sabayon installation...
it worked only after

1. i changed Networkmanager to WICD... remove their service and enable the wicd service...
2. Remove the service of dhcp from systemd
3. remove all the DHCP packages, without deps:

Code: Select all
# equo rm -av --nodeps dhcp dhcpcd

Resuming. I needed to completely deactivate ansd remove the DHCP. Seems to DHCP, when running, it changes the DNS and overwrite the configuration files.

If i understood well, your DNS (s) are not static, but may be that the configs that i carried out, may help you...

in your case you may "capture" the DNS of the DHCP, then use these DNS (s) as "Fixed" ones, and deactivate the dhcp service....
[email protected]
Favorite Distros: Sabayon, Gentoo, Mageia and OpenSUSE
User avatar
Sagely Hen
Posts: 1805
Joined: Fri Nov 16, 2007 1:15
Location: Ribeirão Preto City, São Paulo State, Brazil

Re: Static IPs in dhcpd.conf not written to resolv.conf

Postby twhite » Wed Sep 21, 2016 20:08

Thanks for the suggestions. I'm trying them but can't finish until later. I want dhcp IP but static DNS servers.

I just discovered I have both NetworkManager (NM) and wicd running. I was using an applet client that uses NM. I stopped Nm and connected through the wicd-client GUI. With that I can set static DNS servers which is what I want. Hopefully it will keep the connection better. I don't have the dhcp service running

However WICD evidently still uses the resolvconf framework that manages multiple DNS connections and should write them correctly to /etc/resolv.conf but doesn't. The prepend statement in /etc/dhcp/dhcpd.conf is supposed to be a way to do that. Maybe it will help if I can get rid of resolvconf.
Baby Hen
Posts: 7
Joined: Tue Sep 20, 2016 20:57

Re: Static DNS servers not written to resolv.conf

Postby twhite » Thu Sep 22, 2016 14:25

Kind of Solved...

I changed from NetworkManager to wicd for connection management and disabled NetworkManager, under systemd done with "systemctl disable NetworkManager". Now instead of dropping within a few minutes with NetworkManager, with wicd the connection stays up much better. I'm using wicd-client as the GUI for managing the connections but not the DNS servers.

Resolveconf still didn't write my static DNS servers from /etc/dhcp/dhcpd.conf to /etc/resolv.conf so I still had to manually edit resolv.conf each time after connecting. To fix that I made /etc/resolv.conf a file, not a symlink, and added my static DNS servers to it. I made it immutable so it wouldn't get changed with "chattr +a /etc/resolv.conf"

I didn't uninstall anything. Now my connections are working so much better. I gave up on getting resolvconf and NetworkManager to work. I tried to stay within what some consider the future but can't find clear and understandable documentation on getting it to work for me. I'll try it later when and if the system and documentation is made easy and reliable for me but until then I need to move on.
Baby Hen
Posts: 7
Joined: Tue Sep 20, 2016 20:57

Return to Networking and Wireless

Who is online

Users browsing this forum: No registered users and 1 guest