2020.01.31 DNS and dig - GlenKPeterson/One-off_Examples GitHub Wiki
I recently moved a domain to a different registrar so that we would have control of the settings and could forcibly switch web and email hosts at will. Everyone (including tech support at both ends) was like, "Oh yeah, all the settings just move automatically."
Just in case, I used one of the free online DNS tools to list common values and saved the results. I didn't know yet that these tools only list the most common values and don't even query for anything else.
When I moved the nameservers and all the settings were lost. Everyone was like, "Oh, well if you move the nameservers, of course the settings are lost!" sigh Why would you bother to move the domain host and then leave the nameservers at the old host? Moving the nameservers is what gives you control - it's the whole point!
So I managed to get a .png screenshot of the former settings, which I sent to Amazon's AWS Textract to get converted to text for me. https://aws.amazon.com/textract/
It had a little trouble with a few of the underscores, but otherwise did really well. Unfortunately, some of the longer values like SPF and DKIM were cut off, making them unusable. What to do?
dig linux command-line tool was the answer! It's even installed by default in Ubuntu. After learning how to use it, I fed it all of the DNS keys and record types I was interested in, set it to query the old nameserver (which is still running) and it basically spat out the DNS Zone File for me. For anyone new to DNS (as I was on Monday), the Zone File is where your DNS settings are defined on the nameserver (that might be over-simplified).
https://www.tecmint.com/10-linux-dig-domain-information-groper-commands-to-query-dns/
Here's exactly how I used dig.
temp.txt holds the domains to query, plus the rest of the command line options for that query, one query per line: temp.txt:
somedomain.com +noall +answer
autoconfig.somedomain.com +noall +answer
www.somedomain.com -t CNAME +noall +answer
somedomain.com -t MX +noall +answer
somedomain.com -t TXT +noall +answer
default._domainkey.somedomain.com -t TXT +noall +answer
_autodiscover._tcp.somedomain.com -t SRV +noall +answer
Run dig:
dig @ns1.somewebhosthosting.net -f temp.txt
; <<>> DiG 9.11.3-1ubuntu1.11-Ubuntu <<>> somedomain.com +noall +answer
; (1 server found)
;; global options: +cmd
somedomain.com. 14400 IN A 123.124.125.01
autoconfig.somedomain.com. 14400 IN A 123.124.125.01
www.somedomain.com. 14400 IN CNAME somedomain.com.
somedomain.com. 3600 IN MX 30 somedomain.com.mx2.fusemail.net.
somedomain.com. 3600 IN MX 10 somedomain.com.mx1.fusemail.net.
somedomain.com. 3600 IN MX 20 somedomain.com.mx2.fusemail.net.
somedomain.com. 14400 IN TXT "v=spf1 ip4:123.124.125.01 ..."
default._domainkey.somedomain.com. 14400 IN TXT "v=DKIM1; k=rsa; p=VIRKCsdfWE...;"
_autodiscover._tcp.somedomain.com. 14400 IN SRV 0 0 443 cpanelemaildiscovery.cpanel.net.