dns dig | dig @8888 Hostname | dig redhat.com MX | dig redhat.com NS | dig redhat.com ANY | dig -x 209.132.183.81
In this example, it displays the A record of redhat.com in the “ANSWER SECTION” of the dig command output.
$ dig redhat.com ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> redhat.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62863 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 3 ;; QUESTION SECTION: ;redhat.com. IN A ;; ANSWER SECTION: redhat.com. 37 IN A 209.132.183.81 ;; AUTHORITY SECTION: redhat.com. 73 IN NS ns4.redhat.com. redhat.com. 73 IN NS ns3.redhat.com. redhat.com. 73 IN NS ns2.redhat.com. redhat.com. 73 IN NS ns1.redhat.com. ;; ADDITIONAL SECTION: ns1.redhat.com. 73 IN A 209.132.186.218 ns2.redhat.com. 73 IN A 209.132.183.2 ns3.redhat.com. 73 IN A 209.132.176.100 ;; Query time: 13 msec ;; SERVER: 209.144.50.138#53(209.144.50.138) ;; WHEN: Thu Jan 12 10:09:49 2012 ;; MSG SIZE rcvd: 164
Query MX Records Using dig -t MX
To query MX records, pass MX as an argument to the dig command as shown below.
$ dig redhat.com MX +noall +answer ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> redhat.com MX +noall +answer ;; global options: +cmd redhat.com. 513 IN MX 5 mx1.redhat.com. redhat.com. 513 IN MX 10 mx2.redhat.com.
You can also use option -t to pass the query type (for example: MX) as shown below.
$ dig -t MX redhat.com +noall +answer ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> -t MX redhat.com +noall +answer ;; global options: +cmd redhat.com. 489 IN MX 10 mx2.redhat.com. redhat.com. 489 IN MX 5 mx1.redhat.com.
4. Query NS Records Using dig -t NS
To query the NS record use the type NS as shown below.
$ dig redhat.com NS +noall +answer ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> redhat.com NS +noall +answer ;; global options: +cmd redhat.com. 558 IN NS ns2.redhat.com. redhat.com. 558 IN NS ns1.redhat.com. redhat.com. 558 IN NS ns3.redhat.com. redhat.com. 558 IN NS ns4.redhat.com.
You can also use option -t to pass the query type (for example: NS) as shown below.
$ dig -t NS redhat.com +noall +answer ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> -t NS redhat.com +noall +answer ;; global options: +cmd redhat.com. 543 IN NS ns4.redhat.com. redhat.com. 543 IN NS ns1.redhat.com. redhat.com. 543 IN NS ns3.redhat.com. redhat.com. 543 IN NS ns2.redhat.com.
5. View ALL DNS Records Types Using dig -t ANY
To view all the record types (A, MX, NS, etc.), use ANY as the record type as shown below.
$ dig redhat.com ANY +noall +answer ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> redhat.com ANY +noall +answer ;; global options: +cmd redhat.com. 430 IN MX 5 mx1.redhat.com. redhat.com. 430 IN MX 10 mx2.redhat.com. redhat.com. 521 IN NS ns3.redhat.com. redhat.com. 521 IN NS ns1.redhat.com. redhat.com. 521 IN NS ns4.redhat.com. redhat.com. 521 IN NS ns2.redhat.com.
DNS Reverse Look-up Using dig -x
To perform a DNS reverse look up using the ip-address using dig -x as shown below
For example, if you just have an external ip-address and would like to know the website that belongs to it, do the following.
$ dig -x 209.132.183.81 +short www.redhat.com.
Use a Specific DNS server Using dig @dnsserver
By default dig uses the DNS servers defined in your /etc/resolv.conf file.
If you like to use a different DNS server to perform the query, specify it in the command line as @dnsserver.
The following example uses ns1.redhat.com as the DNS server to get the answer (instead of using the DNS servers from the /etc/resolv.conf file).
$ dig @ns1.redhat.com redhat.com ; <<>> DiG 9.7.3-RedHat-9.7.3-2.el6 <<>> @ns1.redhat.com redhat.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20963 ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 4 ;; WARNING: recursion requested but not available ;; QUESTION SECTION: ;redhat.com. IN A ;; ANSWER SECTION: redhat.com. 60 IN A 209.132.183.81 ;; AUTHORITY SECTION: redhat.com. 600 IN NS ns1.redhat.com. redhat.com. 600 IN NS ns4.redhat.com. redhat.com. 600 IN NS ns3.redhat.com. redhat.com. 600 IN NS ns2.redhat.com. ;; ADDITIONAL SECTION: ns1.redhat.com. 600 IN A 209.132.186.218 ns2.redhat.com. 600 IN A 209.132.183.2 ns3.redhat.com. 600 IN A 209.132.176.100 ns4.redhat.com. 600 IN A 209.132.188.218 ;; Query time: 160 msec ;; SERVER: 209.132.186.218#53(209.132.186.218) ;; WHEN: Thu Jan 12 10:22:11 2012 ;; MSG SIZE rcvd: 180
jenkins@ubuntu:/proc/78010/fd$ dig @8.8.8.8 google.com
; <<>> DiG 9.10.3-P4-Ubuntu <<>> @8.8.8.8 google.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5617
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;google.com. IN A
;; ANSWER SECTION:
google.com. 299 IN A 216.58.209.46
;; Query time: 56 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Sun Jul 15 03:42:07 PDT 2018
;; MSG SIZE rcvd: 55
jenkins@ubuntu:/proc/78010/fd$
Comments
Post a Comment