🖥️dig

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the dig command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██████╗ ██╗ ██████╗ 
#                ██╔══██╗██║██╔════╝ 
#                ██║  ██║██║██║  ███╗
#                ██║  ██║██║██║   ██║
#                ██████╔╝██║╚██████╔╝
#                ╚═════╝ ╚═╝ ╚═════╝ 

#==============================#
# CMD DIG
#==============================##==============================#

dig www.example.com @192.168.1.254
#

dig RandomDomainNameThatDoesNotExistLLC\.com @4.2.2.2
# Sigh.. What is happening to our beloved Internet? (also run 'whois level3\.sucks')

dig +short MX example\.com
# Show the mail servers that mail destined to example.com is going to go. +short for less info than default.

dig +short @resolver1.opendns.com myip.opendns.com
dig +short myip.opendns.com @resolver1.opendns.com
# Get your outgoing IP address

dig +short MX example\.com
# Show the mail servers that mail destined to example.com is going to go. +short for less info than default.

dig -x  IP-Adresse  = hostname.domain
# Reverse Namensauflösung

dig lxu.io AXFR | grep 10.45.8.20
# DNS Vorwärtsauflösung

dig srv041.lxu.io AXFR | grep 10.45.8.20
# DNS Vorwärtsauflösung

dig @8.8.8.8 URL SOA
# Frägt speziell den Google Nameserver ab

dig @8.8.8.8 heise.de MX
# Frägt speziell den Google Nameserver ab

dig @8.8.8.8 heise.de ns
# Frägt speziell den Google Nameserver ab

( seq 1 8 200 ; seq 6 8 200 ) | sort -n | xargs -I{} -n 1 dig +short -x 206.214.251.{}
# Star Wars Episode IV in Reverse DNS.
# Fit that exactly into 140. Yes, that will play Star Wars ASCII Animation with some music in the background. It kinda matches up.

# Get your outgoing IP address - Extract your external IP address using dig
dig +short myip.opendns.com @resolver1.opendns.com
## Explanation: This asks the IP address of myip.opendns.com from the name server resolver1.opendns.com (something you trust), which will return your external IP address. If you do not have dig, you could use these other services instead:
	# curl ipecho.net/plain
	# curl icanhazip.com
	# curl curlmyip.com
	# curl l2.io/ip
	# curl ip.appspot.com
	# curl ifconfig.me/ip
## Limitations: All these methods rely on external services, which might be sometimes temporarily or even permanently down. In that case, find an alternative service.


# 2 commands, 1 grep.
{ dig +short AAAA linux.lxu\.io ; dig +short A linux.lxu\.io; } | grep --color=always 42 

# To run dig (domain information groper)
dig [domain]

# To just get the ip address
dig [domain] +nocomments +noauthority +noadditional +nostats 
    OR
dig [domain] +noall +answer
    OR
dig [domain] +short

# To use a specific query type
dig -t [query type] [domain] [options]
    OR
dig [domain] [query type] [options]

# To view ALL DNS record types use query ANY
dig -t ANY [domain] [options]
    OR
dig [domain] ANY [options]

# To do a DNS reverse look up 
dig -x [ip address] +short

# To use a specific DNS server
dig @[specific DNS] [domain]

# To do a bulk DNS query (where file.txt has all the domains, one to a line)
dig [domain1] [options] [domain2] [options]
    OR
dig -f file.txt [options]

# This command will show the output of MX record:
dig @ns1.myname.com myname.com +short MX

# and this will output A record:
dig @ns1.myname.com myname.com +short A

dig +noall +answer @ns1.myname.com myname.com MX
myname.com.      86400   IN      MX      10 ASPMX2.GOOGLEMAIL.COM.
myname.com.      86400   IN      MX      10 ASPMX3.GOOGLEMAIL.COM.
myname.com.      86400   IN      MX      1 ASPMX.L.GOOGLE.COM.
myname.com.      86400   IN      MX      5 ALT1.ASPMX.L.GOOGLE.COM.
myname.com.      86400   IN      MX      5 ALT2.ASPMX.L.GOOGLE.COM.

# I can almost not imagine this being the actual answer due to the simplicity, but based on what I assume is your answer now, this should do the trick:
dig @ns1.myname.com myname.com +short MX; dig @ns1.myname.com myname.com +short A

# Return a list of all the IPs for a DNS record on one line separated by spaces and make sure to provide a newline at the end so that the prompt is on it's own line.
dig +short http://echo.ntp-fireos.com  | tr '\n' ' ' ; echo 

#==============================##==============================#
# CMD DIG @ lxu.io
#==============================##==============================#

# DEKIM Abfrage - Der DEKIM Key wird an eine Subdomain
dig @8.8.8.8 default._domainkey.lxu.io TXT

#; <<>> DiG 9.10.3-P4-Debian <<>> @8.8.8.8 default._domainkey.lxu.io TXT
#; (1 server found)
#;; global options: +cmd
#;; Got answer:
#;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26556
#;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

#;; OPT PSEUDOSECTION:
#; EDNS: version: 0, flags:; udp: 512
#;; QUESTION SECTION:
#;default._domainkey.lxu.io.	IN	TXT

#;; ANSWER SECTION:
#default._domainkey.lxu.io.	21599 IN TXT	"v=DKIM1; k=rsa; s=email; p=MIGfMA0GCSqGSIb3DQEBAQU4GNADCBiQKBgQClk5nmCP9sLeTlzYrbXHaEftPb31/ZOkP7xaP/UmPC8Lyuc5AL0QmbdokIjoVuVSdIvAiHRDlrSKxDampsB33MdQFKofLJYV2gBpFJ2yNNCBSwMp7hptM+SiOhRrOU8ncTMoZbfksFUQzwUIrLaEYeh6RXJqAd7ejLZ1K1etlQIDAQAB"

#;; Query time: 37 msec
#;; SERVER: 8.8.8.8#53(8.8.8.8)
#;; WHEN: Thu May 23 11:49:08 CEST 2019
#;; MSG SIZE  rcvd: 315


# SPF Eintrag abfragen
dig @8.8.8.8 lxu.io TXT

#; <<>> DiG 9.10.3-P4-Debian <<>> @8.8.8.8 lxu.io TXT
#; (1 server found)
#;; global options: +cmd
#;; Got answer:
#;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30840
#;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

#;; OPT PSEUDOSECTION:
#; EDNS: version: 0, flags:; udp: 512
#;; QUESTION SECTION:
#;lxu.io.			IN	TXT

#;; ANSWER SECTION:
#lxu.io.		1719	IN	TXT	"v=spf1 mx ip4:43.25.150.96/28 ip4:92.86.205.38 ip4:112.19.218.80/28 ip4:44.15.134.160/28 ip4:120.18.235.134 ip4:95.91.11.207 ip4:95.91.11.208 ip4:95.11.1.2 ip4:85.55.220.98 ip4:82.5.142.130 ip4:82.5.142.162 ?all"
#lxu.io.		1719	IN	TXT	"ciscocidomainverification=90f933162873d881b9fc5f7b4da9efa7a494d65acc3ab5b873ba4f6b31ce353"

#;; Query time: 18 msec
#;; SERVER: 8.8.8.8#53(8.8.8.8)
#;; WHEN: Thu May 23 11:50:23 CEST 2019
#;; MSG SIZE  rcvd: 382

# Beides zusammen ergibt einen DMARK Record, der bei uns aus Datenschutzrechtlichen Gründen nicht ist...
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░