[Linux][Network] Dig指令紀錄

[Linux][Network] Dig指令紀錄

純粹自己記錄一下Linux的指令用,

Use specific DNS Server:
# dig @168.95.1.1 www.google.com.tw

Do a reverse lookup using the (-x): 反向查詢(PTR Check):
# dig -x 8.8.8.8

+trace: 查看 DN 從最上層 root 往下跑, 到底經過哪些節點:
# dig +trace www.google.com.tw

+short: 簡短輸出 (寫程式 追蹤方便使用)
# dig +short www.google.com.tw

get the address(es) for yahoo.com:
# dig yahoo.com A +noall +answer

get a list of yahoo’s mail servers:
# dig yahoo.com MX +noall +answer

get a list of DNS servers authoritative for yahoo.com:
# dig yahoo.com NS +noall +answer

get all of the above:
# dig yahoo.com ANY +noall +answer

get ipv6 address using the AAAA option:
# dig www.hinet.net AAAA +short

Get a not-quite-so-short answer:
Note that a short answer is different from only an answer.
The way to get a detailed answer, but without any auxiliary information, is to turn off all the results (+noall) and then turn on only those sections you want.

Get a long answer:
According to its man page, the +multiline option will give you an answer with “the SOA records in a verbose multi-line format with human-readable comments.”
In general, the answers retrieved using the +multiline option will appear more like BIND config files than they will without it.

Do bulk lookups:
If you want to look up a large number of hostnames, you can put them in a file (one name per line) and use the -f option to query each one in turn.
do full lookups for a number of hostnames
# dig -f /path/to/host-list.txt

the same, with more focused output
#dig -f /path/to/host-list.txt +noall +answer

Reference:
https://www.madboa.com/geek/dig/

Add a Comment