Compendium of generic DNS utilities
Return the A record for 'host'.
Always returns a list.
CLI Example:
salt ns1 dig.A www.google.com
Return a list of lists for the MX of 'domain'. Example:
>>> dig.MX('saltstack.org')
[ [10, 'mx01.1and1.com.'], [10, 'mx00.1and1.com.'] ]
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.
CLI Example:
salt ns1 dig.MX google.com
Return a list of IPs of the nameservers for 'domain'
If 'resolve' is False, don't resolve names.
CLI Example:
salt ns1 dig.NS google.com
Return the allowed IPv4 ranges in the SPF record for 'domain'.
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.
CLI Example:
salt ns1 dig.SPF google.com
Check that string ip_addr is a valid IP
CLI Example:
salt ns1 dig.check_ip 127.0.0.1
Append a single line to the /etc/hosts file.
CLI Example:
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.
CLI Examples:
salt '*' dnsutil.hosts_delete /etc/hosts ad1.yuk.co
salt '*' dnsutil.hosts_delete /etc/hosts ad2.yuk.co,ad1.yuk.co
Parse /etc/hosts file.
CLI Example:
salt '*' dnsutil.parse_hosts
Parses a zone file. Can be passed raw zone data on the API level.
CLI Example:
salt ns1 dnsutil.parse_zone /var/lib/named/example.com.zone