DNS DomainNameSystem功能變數名稱系統,根據功能變數名稱查出IP地址 1.dig命令可以顯示整個查詢的過程 root@VM-38-204-ubuntu:~# dig www.sopans.com //這一段是查詢參數和統計 ; > DiG 9.10.3-P4-Ubuntu > www.sopans... ...
DNS DomainNameSystem功能變數名稱系統,根據功能變數名稱查出IP地址 1.dig命令可以顯示整個查詢的過程 root@VM-38-204-ubuntu:~# dig www.sopans.com //這一段是查詢參數和統計 ; <<>> DiG 9.10.3-P4-Ubuntu <<>> www.sopans.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1899 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1 //這一段是查詢內容,查詢www.sopans.com的A記錄,A是Address意思 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;www.sopans.com. IN A //DNS伺服器的答覆,兩條A記錄,575是TTL的值(Time to live)緩存時間575秒內不用重新查詢 ;; ANSWER SECTION: www.sopans.com. 575 IN A 123.206.7.231 www.sopans.com. 575 IN A 115.159.28.111 //DNS伺服器的一些傳輸信息,本機DNS伺服器是10.236.158.106,埠53,返回了75位元組 ;; Query time: 58 msec ;; SERVER: 10.236.158.106#53(10.236.158.106) ;; WHEN: Wed Nov 28 21:36:03 CST 2018 ;; MSG SIZE rcvd: 75 2. +short參數只返回兩條A記錄IP地址 root@VM-38-204-ubuntu:~# dig www.sopans.com +short 123.206.7.231 115.159.28.111 3. 本機DNS伺服器的IP地址位於/etc/resolv.conf root@VM-38-204-ubuntu:~# cat /etc/resolv.conf nameserver 10.236.158.106 nameserver 10.236.158.114 options timeout:1 rotate 4.使用@參數指定DNS伺服器地址,例如指定DNS伺服器地址為8.8.8.8 dig www.sopans.com @8.8.8.8 5.功能變數名稱的層級結構 主機名.次級功能變數名稱.頂級功能變數名稱.根功能變數名稱 www.sopans.com.root ,root可以省略因此會顯示成www.sopans.com. 6.使用+trace參數,查看分級查詢的過程, NS記錄是管理該級功能變數名稱的功能變數名稱伺服器,按每一級逐級查詢的過程 root@VM-38-204-ubuntu:~# dig www.sopans.com +trace . 294897 IN NS c.root-servers.net. . 294897 IN NS d.root-servers.net. . 294897 IN NS e.root-servers.net. . 294897 IN NS f.root-servers.net. . 294897 IN NS g.root-servers.net. . 294897 IN NS h.root-servers.net. . 294897 IN NS i.root-servers.net. . 294897 IN NS a.root-servers.net. . 294897 IN NS j.root-servers.net. . 294897 IN NS k.root-servers.net. . 294897 IN NS l.root-servers.net. . 294897 IN NS m.root-servers.net. . 294897 IN NS b.root-servers.net. ;; Received 239 bytes from 10.236.158.106#53(10.236.158.106) in 0 ms com. 172800 IN NS e.gtld-servers.net. com. 172800 IN NS b.gtld-servers.net. com. 172800 IN NS j.gtld-servers.net. com. 172800 IN NS m.gtld-servers.net. com. 172800 IN NS i.gtld-servers.net. com. 172800 IN NS f.gtld-servers.net. com. 172800 IN NS a.gtld-servers.net. com. 172800 IN NS g.gtld-servers.net. com. 172800 IN NS h.gtld-servers.net. com. 172800 IN NS l.gtld-servers.net. com. 172800 IN NS k.gtld-servers.net. com. 172800 IN NS c.gtld-servers.net. com. 172800 IN NS d.gtld-servers.net. com. 86400 IN DS 30909 8 2 E2D3C916F6DEEAC73294E8268FB5885044A833FC5459588F4A9184CF C41A5766 com. 86400 IN RRSIG DS 8 1 86400 20181211050000 20181128040000 2134 . FeSgJRqqq/LY82e1pAM38Eiu07pepp53zIY23OlA65VDqA4ynhKWb8Ov OKiWzHhWb= ;; Received 1174 bytes from 198.41.0.4#53(a.root-servers.net) in 224 ms sopans.com. 172800 IN NS dns2.hichina.com. sopans.com. 172800 IN NS dns1.hichina.com. CK0POJMG874LJREF7EFN8430QVIT8BSM.com. 86400 IN NSEC3 1 1 0 - CK0Q1GIN43N1ARRC9OSM6QPQR81H5M9A NS SOA RRSIG DNSKEY NSEC3PARAM CK0POJMG874LJREF7EFN8430QVIT8BSM.com. 86400 IN RRSIG NSEC3 8 2 86400 20181202054332 20181125043332 37490 com. R+QjJnuxe+1Bs7+KvcUsTaFaNlUGt+wxLpwdpF9Mxkccm+Re8YJS2R= O7K3MHPOSL4GCSK01O8ER0LQ04KLNNUT.com. 86400 IN NSEC3 1 1 0 - O7K5ETU7SVNP269R4U7KIQRE79H62BPM NS DS RRSIG O7K3MHPOSL4GCSK01O8ER0LQ04KLNNUT.com. 86400 IN RRSIG NSEC3 8 2 86400 20181203062329 20181126051329 37490 com. OKTU40+7GCLv+yWhDXu9GEuklwOKrjTgEVYe51v8C7CgIMiBH0Cysy= ;; Received 886 bytes from 192.43.172.30#53(i.gtld-servers.net) in 362 ms www.sopans.com. 600 IN A 115.159.28.111 www.sopans.com. 600 IN A 123.206.7.231 ;; Received 75 bytes from 140.205.41.23#53(dns1.hichina.com) in 4 ms 7.ns參數和+short參數可以直接查詢該級功能變數名稱的NS記錄 root@VM-38-204-ubuntu:~# dig ns +short sopans.com dns1.hichina.com. dns2.hichina.com. 8. A記錄:地址記錄,功能變數名稱指向的IP地址 MX記錄:郵件記錄,使用郵箱時設置的伺服器地址 CNAME:別名記錄,當前查詢的功能變數名稱跳轉到另一個功能變數名稱, 比如www.baidu.com. 1080 IN CNAME www.a.shifen.com. 這樣的好處是,當要變更www.baidu.com指向的IP地址時,只需更改www.a.shifen.com的就可以了,www.baidu.com不需要變動;一旦設置了cname,就不能設置其他記錄了 NS記錄:管理該級功能變數名稱的功能變數名稱伺服器 PTR:逆向查詢記錄,從IP地址查詢功能變數名稱 9.-x參數是查詢PTR記錄,從IP地址反查功能變數名稱 dig -x 192.30.252.153