DNS Hooks


This script runs after a DNS zone is created/deleted.

Environment variables

  • domain: name of DNS zone

Note: Deleting a missing DNS record does not throw an error. The logic behind this is that the desire for it to be gone was already true. This is especially useful when deleting multiple records where only some are missing, we don't throw an error so they can confirm the requested records are all gone.

However, it may be useful to know that some records were indeed missing prior to the removal. This change will add a warning message for each missing record, eg:
www A did not exist
after the successful text:
Records Deleted

Either way, no error will be thrown after all records are confirmed gone from the zone.


This post script is for the Multi Server Setup API and used for saving a raw DNS zone (CMD_API_DNS_ADMIN) when action=rawsave&domain=domain.com.

The main reason for its existence is because dns_write_post.sh doesn't get triggered for DNS clustering saves. This would be the script to use if a clustered write is required.

Environment variables

  • domain: domain for newly saved domain

The actual data will have to be retrieved from the db file.


This script is called after DNS zone data is updated.

Environment variables

  • DOMAIN: name of DNS zone
  • DOMAIN_IP: IP assigned
  • SERVER_IP: server IP
  • WWW_IP: ip used for www. A records
  • PACKAGE: Current User package
  • SERIAL: Serial used in the zone
  • EMAIL: Authoritative email
  • NS1: Authoritative ns zone
  • INCLUDE_DNSSEC_KEYS: list of paths to DNSSEC keys, one per line... has $include at the beginning
  • Url encoded list of ${resource name}=${Value} pairs of specific DNS record.
    • A
    • AAAA
    • CNAME
    • MX: This only shows the only the value of MX record (${MX server name}=${priority}). Left for backwards compatibility. It is better to user MX_FULL.
    • MX_FULL: List of full mx records (${resource name}=${MX server name} ${priority}
    • NS: This is the only list where the pair is flipped (${value}=${resource name})
    • PTR
    • DS
    • CAA
    • TLSA
    • TXT
    • SPF
    • SRV
  • DEFAULT_TTL: Default TTL set in directadmin.conf
  • [RECORD]_TIME: default TTL value for specific RECORD type

special_exit_code 42

There are some cases where you'd like to have your hook output shown in the result, even if there are no errors.
Most of the time, any output from a script that returned zero (0 == no error), is not displayed.

This feature will allows for the script output to be forced to the visible result, even if it's not normally shown.

Internal directadmin.conf default:


where you can disable the feature by setting it to 0, eg:

./directadmin set special_exit_code 0
service directadmin restart

This is only available for dns_write_post.sh upon development, but this feature can be made available to more hooks upon request, assuming reasonable need.


This script will be called anytime DA makes any call to the named service, including 'start', 'stop', 'restart', 'reload', etc.

This can be used in case you need to trigger something anytime a local change is done on the DA side where named is altered.

The exit code does not affect any code logic, but if you exit with a non-zero result, the output will be saved to /var/log/directadmin/errortaskq.log.

If the exit code is 0 AND there is something to output, then DA will log it to system.log. So if everything went well, do not output anything, as that would just add more data to the system.log.

Environment variables

  • action : given action that was just performed (start, stop, restart, reload, etc.)
  • immediate (0|1): variable indicates if it's a task.queue action, which is 0, or 1 for immediate reloads, mainly for Let's Encrypt wildcards


This script will be called (and all data that was passed to the task.queue) for the:


style calls, will also be passed to this script.

For example, when deleting a zone via the task.queue:

echo "action=dns&do=delete_zone&domain=domain.com" >> /usr/local/directadmin/data/task.queue

the custom hook taskq_dns_post.sh will be called, similar to other action=dns calls.

Environment variables

Depends on dataskq command.

Last Updated: