By default, /etc/resolv.conf is appended static DNS information. This article will a way to prepend appending static DNS information.
Table of Contents
/etc/resolv.conf is the following by default.
- resolvconf is enabled.
- /etc/resolvconf/resolv.conf.d/tail is appended to /etc/resolv.conf. If you use DNS information provided by DHCP server, name resolution may not work correctly.
- systemd-resolved is disabled.
When "nameserver 192.168.11.2" and "search hiroom2.com" are provided by DHCP server, /etc/resolv.conf is the following.
$ cat /etc/resolv.conf # 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 192.168.11.2 search hiroom2.com # ParrotDNS/OpenNIC nameserver 184.108.40.206 nameserver 220.127.116.11 nameserver 18.104.22.168 # Round Robin options rotate
2 Disable /etc/resolvconf/resolv.conf.d/tail
#!/bin/sh -e sudo mv /etc/resolvconf/resolv.conf.d/tail \ /etc/resolvconf/resolv.conf.d/tail.disable sudo systemctl restart resolvconf
3 Enable systemd-resolved
#!/bin/sh -e sudo systemctl disable resolvconf sudo systemctl stop resolvconf sudo rm /etc/resolv.conf sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf sudo systemctl enable systemd-resolved sudo reboot
4 Enable resolvconf
If you need to enable resolvconf after enabling systemd-resolved, run the follwing command.
#!/bin/sh -e sudo rm /etc/resolv.conf sudo systemctl disable systemd-resolved sudo systemctl stop systemd-resolved sudo ln -s /etc/resolvconf/run/resolv.conf /etc/resolv.conf sudo systemctl enable resolvconf sudo reboot