Synchronise cPanel DNS Cluster from Command Line

If you make use of cPanel’s DNS cluster or cPanel DNS Only then you might find this of use.

Typical example where you would use this is scripting, and you want to synchronise your DNS zone files with other servers in the cluster. For example, you may want to automate the deployment of new servers in the DNS cluster. In your script, you want to have  the zone files synchronised.

A second scenario – you have a domain where records are added and removed automatically by a front end system. The system makes modifications to the zone file directly and synchronised changes in a cron every 5 minutes.

The script and path is as follows. Usage is included for your convenience.

$ /scripts/dnscluster
Usage: dnscluster <action> <zone> --help
Actions:
 syncall - make sure all dns zones are
 in sync within the cluster. If the zones
 are out out of sync, the one with the largest
 serial number will be copied to all servers.

 syncalllocal - make sure all dns zones are
 in sync within the cluster. If the zones
 are out out of sync, the one with the largest
 serial number will be copied to all servers.
 Only the local server's zone database will be updated.

 synczone <zone> - sync one zone
 If the zone is out out of sync, the one with the largest
 serial number will be copied to all servers.

 synczonelocal <zone> - sync one zone
 If the zone is out out of sync, the one with the largest
 serial number will be copied to the local server.

'--help' or no args at all will give usage

In the first example I mentioned (sync all zones), the following command would be used:

$ /scripts/dnscluster syncall

For the second example (just a single DNS zone to remote server) you would use:

$ /scripts/dnscluster synczone sysadminspot.com

Note that cPanel DNS synchronisation works on the zone serial. If you’re making direct modifications to the DNS zone file then you must update the serial number to a larger number than the previous. Typically the ten (10) digit serials are the format of YYYYMMDDNN. That is:

  • YYYY = Year in full (2009)
  • MM = Month in full (09)
  • DD = Day in full (26)
  • NN = Version number for that day. Start at 01 and increment. When a new date starts, return to 01.

So if your DNS is not syncing correctly, it’s likely because you are not updating your serials correctly OR your DNS clustering (sync directions, etc) are not setup correctly in cPanel. Login to WHM and setup under Cluster Setup.

For more information on cPanel DNS Only and DNS clustering, check out Understanding cPanel clustered DNS and Setup.

Similar Posts:

VN:F [1.9.22_1171]
Rating: 5.0/5 (4 votes cast)
VN:F [1.9.22_1171]
Rating: +2 (from 2 votes)
Synchronise cPanel DNS Cluster from Command Line, 5.0 out of 5 based on 4 ratings
Tags: , , , , .

What are your thoughts?