10 Linux Dig (Domain Information Groper) Commands to Query DNS
来源:互联网 发布:玄武区网络问政 编辑:程序博客网 时间:2024/05/16 18:19
In our last article we have showed you the most used 8 Nslookup commands with their examples, now here we come with another command line tool calledDig, which is much similar to LinuxNslookup tool. We will see the usage of dig command closely with their examples as shown below.
Dig stands for (Domain Information Groper) is a network administration command-line tool for queryingDomain Name System (DNS) name servers. It is useful for verifying and troubleshootingDNS problems and also to perform DNS lookups and displays the answers that are returned from the name server that were queried. dig is part of the BIND domain name server software suite. dig command replaces older tool such asnslookup and the host. dig tool is available in major Linux distributions.
1. Query Domain “A” Record
# dig yahoo.com; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6_3.2 <<>> yahoo.com;; global options: +cmd;; Got answer:;; ->>HEADER<
Above command causes dig to look up the “A” record for the domain nameyahoo.com. Dig command reads the/etc/resolv.conf file and querying theDNS servers listed there. The response from the DNS server is what dig displays.
Let us understand the output of the commands:
- Lines beginning with ; are comments not part of the information.
- The first line tell us the version of dig (9.8.2) command.
- Next, dig shows the header of the response it received from the DNS server
- Next comes the question section, which simply tells us the query, which in this case is a query for the“A” record ofyahoo.com. TheIN means this is an Internet lookup (in the Internet class).
- The answer section tells us that yahoo.com has the IP address72.30.38.140
- Lastly there are some stats about the query. You can turn off these stats using the+nostats option.
2. Query Domain “A” Record with +short
By default dig is quite verbose. One way to cut down the output is to use the +short option. which will drastically cut the output as shown below.
# dig yahoo.com +short98.139.183.2472.30.38.14098.138.253.109
Note: By default dig looks for the “A” record of the domain specified, but you can specify other records also. TheMX orMail eXchange record tells mail servers how to route the email for the domain. LikewiseTTL,SOA etc.
3. Querying MX Record for Domain
Querying different types of DNS resource records only.
# dig yahoo.com MX; <> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6_3.2 <> yahoo.com MX;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31450;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 24;; QUESTION SECTION:;yahoo.com. IN MX;; ANSWER SECTION:yahoo.com. 33 IN MX 1 mta6.am0.yahoodns.net.yahoo.com. 33 IN MX 1 mta7.am0.yahoodns.net.yahoo.com. 33 IN MX 1 mta5.am0.yahoodns.net.
4. Querying SOA Record for Domain
# dig yahoo.com SOA; <> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6_3.2 <> yahoo.com SOA;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2197;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 7, ADDITIONAL: 7;; QUESTION SECTION:;yahoo.com. IN SOA;; ANSWER SECTION:yahoo.com. 1800 IN SOA ns1.yahoo.com. hostmaster.yahoo-inc.com. 2012081409 3600 300 1814400 600
5. Querying TTL Record for Domain
# dig yahoo.com TTL; <> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6_3.2 <> yahoo.com TTL;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 56156;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0;; QUESTION SECTION:;yahoo.com. IN A;; ANSWER SECTION:yahoo.com. 3589 IN A 98.138.253.109yahoo.com. 3589 IN A 98.139.183.24yahoo.com. 3589 IN A 72.30.38.140
6. Querying only answer section
# dig yahoo.com +nocomments +noquestion +noauthority +noadditional +nostats; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 <<>> yahoo.com +nocomments +noquestion +noauthority +noadditional +nostats;; global options: +cmdyahoo.com. 3442 IN A 72.30.38.140yahoo.com. 3442 IN A 98.138.253.109yahoo.com. 3442 IN A 98.139.183.24
7. Querying ALL DNS Records Types
# dig yahoo.com ANY +noall +answer; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 <<>> yahoo.com ANY +noall +answer;; global options: +cmdyahoo.com. 3509 IN A 72.30.38.140yahoo.com. 3509 IN A 98.138.253.109yahoo.com. 3509 IN A 98.139.183.24yahoo.com. 1709 IN MX 1 mta5.am0.yahoodns.net.yahoo.com. 1709 IN MX 1 mta6.am0.yahoodns.net.yahoo.com. 1709 IN MX 1 mta7.am0.yahoodns.net.yahoo.com. 43109 IN NS ns2.yahoo.com.yahoo.com. 43109 IN NS ns8.yahoo.com.yahoo.com. 43109 IN NS ns3.yahoo.com.yahoo.com. 43109 IN NS ns1.yahoo.com.yahoo.com. 43109 IN NS ns4.yahoo.com.yahoo.com. 43109 IN NS ns5.yahoo.com.yahoo.com. 43109 IN NS ns6.yahoo.com.
8. DNS Reverse Look-up
Querying DNS Reverse Look-up. Only display answer section with using+short.
# dig -x 72.30.38.140 +shortir1.fp.vip.sp2.yahoo.com.
9. Querying Multiple DNS Records
Query multiple website’s DNS specific query viz. MX, NS etc. records.
# dig yahoo.com mx +noall +answer redhat.com ns +noall +answer; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.el6 <<>> yahoo.com mx +noall +answer redhat.com ns +noall +answer;; global options: +cmdyahoo.com. 1740 IN MX 1 mta6.am0.yahoodns.net.yahoo.com. 1740 IN MX 1 mta7.am0.yahoodns.net.yahoo.com. 1740 IN MX 1 mta5.am0.yahoodns.net.redhat.com. 132 IN NS ns1.redhat.com.redhat.com. 132 IN NS ns4.redhat.com.redhat.com. 132 IN NS ns3.redhat.com.redhat.com. 132 IN NS ns2.redhat.com.
10. Create .digrc file
Create .digrc file under $HOME/.digrc to store default dig options.
# dig yahoo.comyahoo.com. 3427 IN A 72.30.38.140yahoo.com. 3427 IN A 98.138.253.109yahoo.com. 3427 IN A 98.139.183.24
We have store +noall +answer options permanently in .digrc file under user’s home directory. Now, whenever dig command execute it will show only answer section of dig output. No Need to type every-time options like+noall +answer.
In this article, we tried to find out dig command which may help you to search (DNS) Domain Name Service related information. Share your thoughts through comment box.
原文地址:http://www.tecmint.com/10-linux-dig-domain-information-groper-commands-to-query-dns/
- 10 Linux Dig (Domain Information Groper) Commands to Query DNS
- [Hacking]Domain Information Groper
- 10个Linux Dig(域信息Groper)命令查询DNS
- Linux - DNS - Command Dig
- 10 Linux DIG Command Examples for DNS Lookup--reference
- 在linux用dig检测dns解析
- linux命令行学习-dig(DNS查询器)
- Linux DNS查看以及dig命令使用
- linux processor and memory information commands
- Linux命令dig,使用指定DNS服务器查询域名
- DNS信息收集-DIG
- dig查询dns解析
- dig DNS解析过程
- dns相关之dig
- dig命令-dns查询
- linux dig
- 如何在windows 10 中安装 dig DNS 工具
- How To Get High Quality Information About Query Performance
- android中如何更改EditText 的光标颜色
- 获取当前模块句柄GetModuleHandle
- EL表达式之sessionScope
- INSTALL_FAILED_VERSION_DOWNGRADE报错
- linux bash shell 中getopts 命令 和 python 中 getopt 函数的比较总结
- 10 Linux Dig (Domain Information Groper) Commands to Query DNS
- Farey级数
- 毕业求职压力大 职能培训帮助多
- TH-AFE 交流采样与变送器鉴定装置
- (Jquery功能篇)easy UI 验证功能
- JAVASCRIPT类的定义(不懂的时候可以看一看)
- sql server编程语法
- MySQL慢查询
- 有关tty hangup