Linux Basic Command - dig

Posted by rjs34 on Tue, 01 Oct 2019 08:03:53 +0200

dig

  Di is a DNS query tool, most administrators will use the dig command to solve DNS problems.
  The scope of application of this command: Red Hat, RHEL, Ubuntu, CentOS, Fedora.

1. Grammar

  dig [option]

2. List of parameters

  @server
        Specify server address
  -b host
        Specify which host to query through
  -f file
        Query from a specified file
  -p port
        Designated port
  -t type
        Specify the DNS type to query, such as A MX PRT
  -x ip
        Specify DNS you want to query, enter ip to get domain name
  -4
        Using ipv4
  -6
        Using ipv6

3. Example
1) Query domain name information

  [root@localhost ~]# dig www.baidu.com
  ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6 <<>> www.baidu.com
  ;; global options: +cmd
  ;; Got answer:
  ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23028
  ;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

  ;; QUESTION SECTION:
  ;www.baidu.com.    IN    A

  ;; ANSWER SECTION:
  www.baidu.com.    572    IN    CNAME    www.a.shifen.com.
  www.a.shifen.com.    65    IN    A    111.13.100.92
  www.a.shifen.com.    65    IN    A    111.13.100.91

  ;; Query time: 103 msec
  ;; SERVER: 172.20.10.1#53(172.20.10.1)
  ;; WHEN: Sat Oct  6 08:08:04 2018
  ;; MSG SIZE  rcvd: 90

2) Reverse Query

  [root@localhost ~]# dig -t a -x 111.13.100.92

  ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6 <<>> -t a -x 111.13.100.92
  ;; global options: +cmd
  ;; Got answer:
  ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 8225
  ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

  ;; QUESTION SECTION:
  ;92.100.13.111.in-addr.arpa.    IN    A

  ;; Query time: 81 msec
  ;; SERVER: 172.20.10.1#53(172.20.10.1)
  ;; WHEN: Sat Oct  6 08:09:51 2018
  ;; MSG SIZE  rcvd: 44
  We have built a platform for Linux learning. Now we have a prototype. You can use it for reference.
  Link: https://pan.baidu.com/s/1GOLVU2CbpBNGtunzt VpaCQ password: n7bk 

Topics: Linux DNS Red Hat RHEL Ubuntu