0

I found a number of answers saying that this is not the purpose of a slave DNS server, and that the depending on bind configuration / version (?), modifying the zonefile could be insufficient, as bind could use a binary file.

My scenario is the following : let's say I have two machines, A and B. A hosts the master DNS and B hosts the slave DNS. A and B also host web services.

If A is down for any reason, I would like to transfer web services to B. To do so, I would also update the DNS A entries.

Is this possible in a reproducible way, or do I have to promote the slave server to master, which is less ideal ?

Thanks a lot.

1

As you've mentioned, the whole point of a slave zone is that it transfers the zone data from the master. Editing that file will result in undefined behavior to the best of my knowledge.

The "safe" way to do this would be to change the zone config in your named.conf on the backup server from being a slave to being master, but pointing that master zone to the same zone file (the file directive) on disk, and commenting out the master directive.

You can then alter the zone file as you need and the backup server is now the master for the zone.

Another option is to set both servers to be 'master', and use an out-of-band file sync tool (eg, rsync, unison, syncthing) to keep the zone file on both hosts in sync. If you use a 2-way file sync tool, then changes on either server will sync to the other. You will need to devise a method to have named reload the zone file when changes are made - this could be as simple as reloading on a cron/systemd timer, or using inotify or systemd paths (see man system.path) to execute the reload whenever the file changes on disk.

An example systemd path could look like this (saved as /etc/systemd/system/dns-zones.path):

[Unit]
Description=Triggers a reload of named zones when zone file changes on disk

[Path]
PathChanged=/var/named/zones/example.com.zone

[Install]
WantedBy=multi-user.target
WantedBy=system-update.target

You need a corresponding .service unit to do the actual reload (ie /etc/systemd/system/dns-zones.service)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.