Compendium of generic DNS utilities.
Some functions in the
dnsutil execution module depend on
Return the A record(s) for
Always returns a list.
salt ns1 dnsutil.A www.google.com
Return the AAAA record(s) for
Always returns a list.
New in version 2014.7.5.
salt ns1 dnsutil.AAAA www.google.com
Return a list of lists for the MX of
If the 'resolve' argument is True, resolve IPs for the servers.
It's limited to one IP, because although in practice it's very rarely a round robin, it is an acceptable configuration and pulling just one IP lets the data be similar to the non-resolved version. If you think an MX has multiple IPs, don't use the resolver here, resolve them in a separate step.
salt ns1 dnsutil.MX google.com
Return a list of IPs of the nameservers for
If 'resolve' is False, don't resolve names.
salt ns1 dnsutil.NS google.com
Return the allowed IPv4 ranges in the SPF record for
If record is
SPF and the SPF record is empty, the TXT record will be
searched automatically. If you know the domain uses TXT and not SPF,
specifying that will save a lookup.
salt ns1 dnsutil.SPF google.com
Check that string ip_addr is a valid IP
salt ns1 dnsutil.check_ip 127.0.0.1
Append a single line to the /etc/hosts file.
salt '*' dnsutil.hosts_append /etc/hosts 127.0.0.1 ad1.yuk.co,ad2.yuk.co
Remove a host from the /etc/hosts file. If doing so will leave a line containing only an IP address, then the line will be deleted. This function will leave comments and blank lines intact.
salt '*' dnsutil.hosts_remove /etc/hosts ad1.yuk.co salt '*' dnsutil.hosts_remove /etc/hosts ad2.yuk.co,ad1.yuk.co
Parse /etc/hosts file.
salt '*' dnsutil.parse_hosts
Parses a zone file. Can be passed raw zone data on the API level.
salt ns1 dnsutil.parse_zone /var/lib/named/example.com.zone
Return, store and update a dns serial for your zone files.
zone: a keyword for a specific zone
update: store an updated version of the serial in a grain
update is False, the function will retrieve an existing serial or
return the current date if no serial is stored. Nothing will be stored
update is True, the function will set the serial to the current date
if none exist or if the existing serial is for a previous date. If a serial
for greater than the current date is already stored, the function will
This module stores the serial in a grain, you can explicitly set the
stored value as a grain named
salt ns1 dnsutil.serial example.com