[日常] DNS解析概述

[日常] DNS解析概述,第1张

概述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.231www.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: 752.+short参数只返回两条A记录IP地址root@VM-38-204-ubuntu:~# dig www.sopans.com +short123.206.7.231115.159.28.1113.本机DNS服务器的IP地址位于/etc/resolv.confroot@VM-38-204-ubuntu:~# cat /etc/resolv.confnameserver 10.236.158.106nameserver 10.236.158.114options timeout:1 rotate4.使用@参数指定DNS服务器地址,例如指定DNS服务器地址为8.8.8.8dig www.sopans.com @8.8.8.85.域名的层级结构主机名.次级域名.顶级域名.根域名 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 mscom. 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 C41A5766com. 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 mssopans.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 NSEC3PARAMCK0POJMG874LJREF7EFN8430QVIT8BSM.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 RRSIGO7K3MHPOSL4GCSK01O8ER0LQ04KLNNUT.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 mswww.sopans.com. 600 IN A 115.159.28.111www.sopans.com. 600 IN A 123.206.7.231;; Received 75 bytes from 140.205.41.23#53(dns1.hichina.com) in 4 ms7.ns参数和+short参数可以直接查询该级域名的NS记录root@VM-38-204-ubuntu:~# dig ns +short sopans.comdns1.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 

<div >

1.root@VM-38-204-ubuntu:~<span >#<span > dig www.sopans.com
//这一段是查询参数和统计
; <<>> DiG 9.10.3-P4-Ubuntu <<>> www.sopans.<span >com
;; <span >global options: +<span >cmd
;; Got answer:<span >
;; ->><span >header<<- opcode: query,status: NOERROR,ID: 1899<span >
;; flags: qr rd ra; query: 1,ANSWER: 2,AUTHORITY: 0,ADDITIONAL: 1

<span >//<span >这一段是查询内容,查询www.sopans.com的A记录,A是Address意思
;; OPT PSEUDOSECTION:<span >
; ednS: version: 0,flags:; udp: 4096<span >
;; QUESTION SECTION:<span >
;www.sopans.com.<span > IN A

<span >//<span >DNS服务器的答复,两条A记录,575是TTL的值(Time to live)缓存时间575秒内不用重新查询
;; ANSWER SECTION:<span >
www.sopans.com. 575 IN A 123.206.7.231<span >
www.sopans.com. 575 IN A 115.159.28.111

<span >//<span >DNS服务器的一些传输信息,本机DNS服务器是10.236.158.106,端口53,返回了75字节
;; query <span >time: 58<span > msec
;; SERVER: 10.236.158.106<span >#<span >53(10.236.158.106)
;; WHEN: Wed Nov 28 21:36:03 CST 2018<span >
;; MSG SIZE rcvd: 75

+<span >short参数只返回两条A记录IP地址
root@VM-38-204-ubuntu:~<span >#<span > dig www.sopans.com +short
123.206.7.231
115.159.28.111

3.<span >
本机DNS服务器的IP地址位于/etc/resolv.<span >conf
root@VM-38-204-ubuntu:~<span >#<span > cat /etc/resolv.conf
nameserver 10.236.158.106<span >
nameserver 10.236.158.114<span >
options timeout:1<span > rotate

4.使用@参数指定DNS服务器地址,例如指定DNS服务器地址为8.8.8.8<span >
dig www.sopans.com @8.8.8.8

5.<span >域名的层级结构
主机名.次级域名.顶级域名.根域名 www.sopans.com.root,root可以省略因此会显示成www.sopans.com.

6.使用+<span >trace参数,查看分级查询的过程,
NS记录是管理该级域名的域名服务器,按每一级逐级查询的过程
root@VM-38-204-ubuntu:~<span >#<span > 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.<span >
;; Received 239 bytes from 10.236.158.106<span >#<span >53(10.236.158.106) in 0 ms
<span >
com. 172800 IN NS e.gtld-servers.net.<span >
com. 172800 IN NS b.gtld-servers.net.<span >
com. 172800 IN NS j.gtld-servers.net.<span >
com. 172800 IN NS m.gtld-servers.net.<span >
com. 172800 IN NS i.gtld-servers.net.<span >
com. 172800 IN NS f.gtld-servers.net.<span >
com. 172800 IN NS a.gtld-servers.net.<span >
com. 172800 IN NS g.gtld-servers.net.<span >
com. 172800 IN NS h.gtld-servers.net.<span >
com. 172800 IN NS l.gtld-servers.net.<span >
com. 172800 IN NS k.gtld-servers.net.<span >
com. 172800 IN NS c.gtld-servers.net.<span >
com. 172800 IN NS d.gtld-servers.net.<span >
com. 86400 IN DS 30909 8 2<span > E2D3C916F6DEEAC73294E8268FB5885044A833FC5459588F4A9184CF C41A5766
com. 86400 IN RRSIG DS 8 1 86400 20181211050000 20181128040000 2134 . FeSgJRqqq/LY82e1pAM38Eiu07pepp53zIY23olA65VDqA4ynhKWb8Ov OKiWzHhWb=<span >
;; Received 1174 bytes from 198.41.0.4<span >#<span >53(a.root-servers.net) in 224 ms
<span >
sopans.com. 172800 IN NS dns2.hichina.com.<span >
sopans.com. 172800 IN NS dns1.hichina.com.<span >
CK0POJMG874LJREF7EFN8430QVIT8BSM.com. 86400 IN NSEC3 1 1 0 -<span > 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=<span >
O7K3MHPOSL4GCSK01O8ER0LQ04KLNNUT.com. 86400 IN NSEC3 1 1 0 -<span > O7K5ETU7SVNP269R4U7KiqrE79H62BPM NS DS RRSIG
O7K3MHPOSL4GCSK01O8ER0LQ04KLNNUT.com. 86400 IN RRSIG NSEC3 8 2 86400 20181203062329 20181126051329 37490 com. OKTU40+7GCLv+yWhDXu9GEuklwOKrjTgEVYe51v8C7CgIMiBH0Cysy=<span >
;; Received 886 bytes from 192.43.172.30<span >#<span >53(i.gtld-servers.net) in 362 ms
<span >
www.sopans.com. 600 IN A 115.159.28.111<span >
www.sopans.com. 600 IN A 123.206.7.231<span >
;; Received 75 bytes from 140.205.41.23<span >#<span >53(dns1.hichina.com) in 4 ms

7.ns参数和+<span >short参数可以直接查询该级域名的NS记录
root@VM-38-204-ubuntu:~<span >#<span > dig ns +short sopans.com
dns1.hichina.com.<span >
dns2.hichina.com.

8.<span >
A记录:地址记录,域名指向的IP地址
MX记录:邮件记录,使用邮箱时设置的服务器地址
Cname:<span >别名记录,当前查询的域名跳转到另一个域名,
比如www.baIDu.com. 1080 IN Cname www.a.shifen.com.<span >
这样的好处是,当要变更www.baIDu.com指向的IP地址时,只需更改www.a.shifen.com的就可以了,www.baIDu.com不需要变动;一旦设置了cname,<span >就不能设置其他记录了
NS记录:管理该级域名的域名服务器
PTR:<span >逆向查询记录,从IP地址查询域名

9.-<span >x参数是查询PTR记录,从IP地址反查域名
dig -x 192.30.252.153

总结

以上是内存溢出为你收集整理的[日常] DNS解析概述全部内容,希望文章能够帮你解决[日常] DNS解析概述所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:http://outofmemory.cn/yw/1051147.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-25
下一篇2022-05-25

发表评论

登录后才能评论

评论列表(0条)

    保存