25th Oct 2023
To look up specific records, use dig @server type name
:
# Use Google's 8.8.8.8 DNS server to lookup MX records for domain josephuspaye.com
dig @8.8.8.8 mx josephuspaye.com
Given an IP, to make a reverse query, use dig -x ip
:
# Looks up the PTR record for the given IP.
# PTR provides (ip -> name) like A provides (name -> ip)
dig -x 127.0.0.1
For more concise formatting, add +noall +answer
:
> dig +noall +answer @8.8.8.8 ns josephuspaye.com
josephuspaye.com. 21600 IN NS ivan.ns.cloudflare.com.
josephuspaye.com. 21600 IN NS melany.ns.cloudflare.com.
For even shorter formatting (just the record values), use +short
:
> dig +short @8.8.8.8 ns josephuspaye.com
ivan.ns.cloudflare.com.
melany.ns.cloudflare.com.
To get all records (except CNAME
, for that you need to query the specific subdomain for the ). Note this only for DNS servers that respond to any
queries (see https://serverfault.com/a/294370).
dig +noall +answer @8.8.8.8 afful.com.au any
afful.com.au. 19758 IN AAAA 2400:8907::f03c:93ff:febb:dfa8
afful.com.au. 19758 IN A 172.105.173.14
afful.com.au. 1758 IN TXT "MS=ms12632407"
afful.com.au. 1758 IN TXT "v=spf1 include:spf.protection.outlook.com -all"
afful.com.au. 19758 IN SOA ns1.linode.com. websites.josephuspaye.com. 2021000013 14400 14400 1209600 86400
afful.com.au. 19758 IN NS ns5.linode.com.
afful.com.au. 19758 IN NS ns1.linode.com.
afful.com.au. 19758 IN NS ns2.linode.com.
afful.com.au. 19758 IN NS ns4.linode.com.
afful.com.au. 19758 IN NS ns3.linode.com.
afful.com.au. 1758 IN MX 0 afful-com-au.mail.protection.outlook.com.
More reading
dig