[日常] DNS解析概述
程序员文章站
2022-04-09 19:06:03
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
上一篇: CAST() 函数
下一篇: js 原型,原型链,原型链继承浅析