Skip to main content

DNS via Bind for local Resolution on Ubuntu 18 04

·1 min

DNS via Bind for local Resolution on Ubuntu 18.04 #

On Host System #

  • on the system you want to host bind, you need to make sure that port 53 is not in use:
  • Disable and stop the systemd-resolved service:
    sudo systemctl disable systemd-resolved.service
    sudo systemctl stop systemd-resolved
  • Then put the following line in the [main] section of your /etc/NetworkManager/NetworkManager.conf:
    dns=default
  • Delete the symlink /etc/resolv.conf
    sudo rm /etc/resolv.conf
  • Restart network-manager
    sudo service network-manager restart

On the Client System #

  • You can run this DNS container locally without having to worry to affect any corporate DNS server that are given to you via DHCP.

  • Add the following line to the very beginning to /etc/dhcp/dhclient.conf:

    prepend domain-name-servers 127.0.0.1;
  • Restart network manager
    # Via service command
    sudo service network-manager restart
    # Or the systemd way
    sudo systemctl restart network-manager
  • This will make sure that whenever your /etc/resolv.conf is deployed, you will have 127.0.0.1 as the first entry and also make use of any other DNS server which are deployed via the LAN’s DHCP server.

    • If cytopia/bind is not running, it does not affect the name resolution, because you will still have entries in /etc/resolv.conf.
  • be sure that dns comes before mdns4_minimal in /etc/nsswitch.conf:

ie.

    hosts: files dns mdns4_minimal [NOTFOUND=return]

rather than

    hosts: files mdns4_minimal [NOTFOUND=return] dns