怎样查看DNS服务的IP

IP地址是网络上标识站点的数字地址,为了方便记忆,采用域名来代替IP地址标识站点地址。域名解析就是域名到IP地址的转换过程。域名的解析工作由DNS服务器完成。域名解析的流程是:域名-DNS(域名解析服务器)-网站空间。

查看本地DNS服务IP

本地的DNS IP一般在/etc/resolv.conf文件中。

  1. 直接用cat查看

    cat /etc/resolv.conf 
    #
    # macOS Notice
    #
    # This file is not consulted for DNS hostname resolution, address
    # resolution, or the DNS query routing mechanism used by most
    # processes on this system.
    #
    # To view the DNS configuration used by this system, use:
    #   scutil --dns
    #
    # SEE ALSO
    #   dns-sd(1), scutil(8)
    #
    # This file is automatically generated.
    #
    nameserver 192.168.1.1
    
  2. grep一把

    grep nameserver /etc/resolv.conf 
    nameserver 192.168.1.1
    

查看某个网站的DNS和Server IP

dig baidu.com

; <<>> DiG 9.10.6 <<>> baidu.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5605
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;baidu.com.			IN	A

;; ANSWER SECTION:
baidu.com.		377	IN	A	220.181.38.148
baidu.com.		377	IN	A	39.156.69.79

;; Query time: 1 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Sun Aug 18 14:51:20 +08 2019
;; MSG SIZE  rcvd: 70

这里解析出DNS IP是192.168.1.1,baidu.com Server的IP是220.181.38.148和39.156.69.79。

本文由 络壳 原创或整理,转载请注明出处