Custom DNS over DHCP

I tried to set some custom DNS server on a raspbian server. I was expecting some black magic. I stumbled upon weird stuff trying to find some hidden secret, but it was just one tool and one config line to edit.

The tool is resolvconf. It'll tell its name in /etc/resolv.conf, saying it's a managed file and can't survive a reboot if manually edited.

Answer:

  • The config to edit is in /etc/resolvconf.conf.
  • You'll set name_servers=127.0.0.1. Change the IP and you'll be good to go.

The first time I looked at the config file, I just missed that line and I kept on trying to find some weird shamanic scripts to configure. I learned some stuff along the way:

  • resolvconf will deal with a couple of DNS services. If you host one of them, it should pick it up.
  • You can reload it doing sudo resolvconf -u

Other tools could do the job, like NetworkManager or the systemd tool (renamed as resolvectl recently I think) but if I have what I need already in place, why try to fetch and configure something else ?

Avatar
Julien Pericat
Linux Sysadmin, SysOps & DevOps friendly

Happily automating and putting things in containers.