If you for whatever reason don’t want to use a secondary name server provider, but still want to have a secondary name server for your Mail-in-a-Box instance, it’s relatively easy to set up NSD as a secondary nameserver yourself on a second VPS. I installed it on a Debian 11 VPS but this should work exactly the same on Ubuntu.
Spin up a VPS with Debian 11 or Ubuntu 20.04. The cheapest plan with 1 core and 512MB of RAM should be more than enough. But make sure they offer you a “real” virtual machine e.g. KVM and not something like an OpenVZ container…
Go to the “Custom DNS” section of the Mail-in-a-Box admin interface and create an A record for your secondary nameserver and point it to the IP address of the VPS.
Important! You cannot use ns2.box.yourdomain.tld. Other than that you can use whatever subdomain you want. In this example we keep it simple and use
ns3.box.yourdomain.tld IN A 184.108.40.206 # IP address of the second VPS
Login to the DNS-Settings-Panel of your registrar and change the second glue record for the domain name you’re hosting your Mail-in-a-Box instance on:
ns1.box.yourdomain.tld 220.127.116.11 # IP address of your MiaB (stays as is) ns3.box.yourdomain.tld 18.104.22.168 # name and IP address of the 2ndry server / new VPS`
Then change the secondary nameserver entries for all the domain names you’re hosting on your Mail-in-a-Box instance:
Nameserver 1: ns1.box.yourdomain.tld # name of your MiaB instance (stays as is) Nameserver 2: ns3.box.yourdomain.tld # name of the 2ndry server / new VPS
Log into your newly created VPS via SSH and change to a root shell:
Upgrade all packages:
apt update && apt dist-upgrade -y
Set the correct timezone:
timedatectl set-timezone "Europe/Zurich"
Install nsd and additional tools
apt install -y nsd dnsutils lnav
Create the directory for the zone files (Probably not needed but I wanted it to be identical to MiaB)
Edit the file
/etc/nsd/nsd.conf as in the example below:
server: ip-address: 22.214.171.124 #IP address of the 2ndry server (this server) hide-version: yes verbosity: 2 server-count: 1 zonesdir: "/etc/nsd/zones" # probably not needed but I wanted it to be identical to MiaB zone: name: yourdomain.tld zonefile: yourdomain.tld.zone allow-notify: 126.96.36.199 NOKEY # IP address of your MiaB server request-xfr: 188.8.131.52 NOKEY # IP address of your MiaB server # If you are hosting more than one domain on your MiaB instance add them like this... zone: name: yourotherdomain.tld zonefile: yourotherdomain.tld.zone allow-notify: 184.108.40.206 NOKEY # IP address of your MiaB server request-xfr: 220.127.116.11 NOKEY # IP address of your MiaB server
After you’re done you can use
nsd-control to reconfigure NSD…
or simply restart the service:
systemctl restart nsd
Enter the name e.g.
ns3.box.yourdomain.tld of your newly created secondary
nameserver to the “Using a secondary nameserver” field in the “Custom DNS” section of the Mail-in-a-Box admin interface. The zone information should get automatically transfred to your secondary server.
Check the syslog…
If the zone transfer was successful, you should see a line similiar to that in the syslog:
Apr 19 13:56:06 ns3 nsd: [2022-04-19 13:56:06.755] nsd: info: notify for yourdomian.tld from 18.104.22.168
Of course you can also check with the dig command from another server or from your PC…
dig NS yourdomain.tld @ns3.box.yourdomain.tld
…or you could use one of the many online tools like DNS Check and DNS Report Tools - Comprehensive DNS Tests - MxToolBox or https://dnschecker.org etc…
Hope this helps somebody