DNS抓包分析--wireshark
生活随笔
收集整理的這篇文章主要介紹了
DNS抓包分析--wireshark
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
DNS抓包分析–wireshark
DNS-(Domain Name System,域名系統),是因特網上作為余名和IP地址相互映射的一個分布式數據庫,能夠使用戶更加方便地訪問互聯網,而不是去記住能夠被機器直接讀取的IP數串。通過主機名,從而得到主機名對應的IP地址的過程叫做余名解析或者主機名解析。DNS運行在UDP協議之上,使用端口號53。
這里主要說明DNS如何使用wireshark抓包定位的,關于什么是DNS可以結合百度百科看下,已經寫的很詳細了。簡單的來說域名就是你家地址浙江杭州濱江…,要把郵件寄到你家但是電腦不能直接識別地址就需要轉換成東經多少北緯多少的IP地址,這個轉換工作由DNS完成,DNS根服務器,其他的鏡像服務器根據根服務器來進行地址轉換.
DNS有稱為IP翻譯官,其具體工作流程如下:
Local Host | Foreign|+---------+ +----------+ | +--------+| | user queries | |queries | | || User |-------------->| |---------|->|Foreign || Program | | Resolver | | | Name || |<--------------| |<--------|--| Server || | user responses| |responses| | |+---------+ +----------+ | +--------+| A |cache additions | | references |V | |+----------+ || cache | |+----------+ |舉例:
DNS的兩種查詢方式
- 遞歸查詢,主機向本地域名服務器的查詢一般都是采用遞歸查詢,如果主機所詢問的本地域名服務器不指定被查詢的域名的IP地址,那么本地域名服務器就以客戶的身份,向其他根域名服務器繼續發出查詢請求報文。
- 迭代查詢,本地域名服務器向根域名服務器的查詢通常采用迭代查詢,當根域名服務器收到本地域名服務器的查詢請求報文時,要么給出要查詢的IP地址,要么告訴本地域名服務器下一步向那個域名服務器進行查詢,然后讓本地域名服務器進行后續的查詢。
DNS常用問題類型
DNS查詢和相應中所使用的類型域,指明了這個查詢或者響應的資源記錄類型。
| 1 | A | IPv4主機地址 |
| 2 | NS | 權威域名服務器 |
| 5 | CNAME | 規范別名,定義主機正式名字的別名 |
| 12 | PTR | 指針,把IP地址轉換為域名 |
| 15 | MX | 郵件交換記錄,用于電子郵件系統發送 郵件根據收件人的地址后綴 定位郵件服務器 |
| 16 | TXT | 文本字符串 |
| 28 | AAAA | IPv6主機地址 |
| 251 | IXFR | 增量區域傳送 |
| 252 | AXFR | 完整區域傳送 |
捕獲DNS數據
開啟wireshark開始抓包,然后使用dig觸發一個DNS查詢
dig www.baidu.com命令dig的常用方式和說明
dig DNS Lookup utility.- Lookup the IP(s) associated with a hostname (A records):dig +short {{example.com}}- Lookup the mail server(s) associated with a given domain name (MX record):dig +short {{example.com}} MX- Get all types of records for a given domain name:dig {{example.com}} ANY- Specify an alternate DNS server to query:dig @{{8.8.8.8}} {{example.com}}- Perform a reverse DNS lookup on an IP address (PTR record):dig -x {{8.8.8.8}}- Find authoritative name servers for the zone and display SOA records:dig +nssearch {{example.com}}- Perform iterative queries and display the entire trace path to resolve a domain name:dig +trace {{example.com}}DNS報文格式解析
1 1 1 1 1 10 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+| ID |+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+|QR| Opcode |AA|TC|RD|RA| Z | RCODE |+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+| QDCOUNT |+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+| ANCOUNT |+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+| NSCOUNT |+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+| ARCOUNT |+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+- DNS ID號:用來對應DNS查詢和DNS響應
- 查詢/響應(Query/Response):用來指明這個報文是DNS查詢還是響應,占1比特位,1表示是響應,0表示是查詢
- 操作代碼OpCode: 用來定義消息中請求的類型,占4比特位
- AA: 權威應答,如果設置了這個位,這說明這個響應是由權威域名服務器發出的,占1比特位。
- TC:截斷,由于響應時間太長,無法接入報文而被截斷。該標志為1時說明響應已經超過512字節并已被截斷
- 期望遞歸(Recursion Desired,RD):請求中設定了這個值,說明DNS客戶端在目標域名服務器不含有所請求信息的情況下,要求進行遞歸查詢。
- RA: 可用遞歸,當設置了這個值,說明域名服務器支持遞歸查詢。
- 保留Z: 全部設置為0,但是有時候會作為RCODE位的擴展
- RCODE: Response Code 響應代碼,在DNS響應中,用來指明錯誤,占4個比特位。 含義如下:
- 0表示沒有錯誤
- 1表示個數錯誤
- 2表示域名服務器上存在問題
- 3表示域參數問題
- 4表示類型不支持
- 5表示管理上被禁止
- 6-15表示保留
- QDCOUNT:問題計數,在問題區段中的條目數
- ANCOUNT: 在回答區段中的條目數
- NSCOUNT: 域名服務器計數,在權威區段的域名資源記錄數
- ARCOUNT: 再額外信息區段中的其他資源記錄數
報文說明
Domain Name System (query)Transaction ID: 0x9ad0 #事務IDFlags: 0x0000 Standard query #報文中的標志字段0... .... .... .... = Response: Message is a query#QR字段, 值為0, 因為是一個請求包.000 0... .... .... = Opcode: Standard query (0)#Opcode字段, 值為0, 因為是標準查詢.... ..0. .... .... = Truncated: Message is not truncated#TC字段.... ...0 .... .... = Recursion desired: Don't do query recursively #RD字段.... .... .0.. .... = Z: reserved (0) #保留字段, 值為0.... .... ...0 .... = Non-authenticated data: Unacceptable #保留字段, 值為0Questions: 1 #問題計數, 這里有1個問題Answer RRs: 0 #回答資源記錄數Authority RRs: 0 #權威名稱服務器計數Additional RRs: 0 #附加資源記錄數協議交互過程報文
Frame 5: 87 bytes on wire (696 bits), 87 bytes captured (696 bits) on interface wlp4s0, id 0 Ethernet II, Src: Chongqin_e1:18:a9 (40:23:43:e1:18:a9), Dst: HIWIFI_65:b0:40 (d4:ee:07:65:b0:40) Internet Protocol Version 4, Src: 192.168.199.235, Dst: 192.168.199.1 User Datagram Protocol, Src Port: 36025, Dst Port: 53 Domain Name System (query) # DNS協議Transaction ID: 0x9f1c # 事務ID編號Flags: 0x0100 Standard query0... .... .... .... = Response: Message is a query # DNS查詢.000 0... .... .... = Opcode: Standard query (0) #操作代碼.... ..0. .... .... = Truncated: Message is not truncated #截斷.... ...1 .... .... = Recursion desired: Do query recursively #期望遞歸.... .... .0.. .... = Z: reserved (0).... .... ...0 .... = Non-authenticated data: UnacceptableQuestions: 1Answer RRs: 0Authority RRs: 0Additional RRs: 1Querieswww.a.shifen.com: type A, class INName: www.a.shifen.com[Name Length: 16][Label Count: 4]Type: A (Host Address) (1)Class: IN (0x0001)Additional records<Root>: type OPT[Response In: 6]No. Time Source Destination Protocol Length Info6 0.013373576 192.168.199.1 192.168.199.235 DNS 289 Standard query response 0x9f1c A www.a.shifen.com A 180.101.49.12 A 180.101.49.11 NS ns3.a.shifen.com NS ns4.a.shifen.com NS ns5.a.shifen.com NS ns1.a.shifen.com NS ns2.a.shifen.com A 61.135.165.224 A 220.181.33.32 A 112.80.255.253 A 14.215.177.229 A 180.76.76.95 OPTFrame 6: 289 bytes on wire (2312 bits), 289 bytes captured (2312 bits) on interface wlp4s0, id 0 Ethernet II, Src: HIWIFI_65:b0:40 (d4:ee:07:65:b0:40), Dst: Chongqin_e1:18:a9 (40:23:43:e1:18:a9) Internet Protocol Version 4, Src: 192.168.199.1, Dst: 192.168.199.235 User Datagram Protocol, Src Port: 53, Dst Port: 36025 Domain Name System (response)Transaction ID: 0x9f1cFlags: 0x8180 Standard query response, No error1... .... .... .... = Response: Message is a response #DNS回復.000 0... .... .... = Opcode: Standard query (0).... .0.. .... .... = Authoritative: Server is not an authority for domain # 非權威應答.... ..0. .... .... = Truncated: Message is not truncated.... ...1 .... .... = Recursion desired: Do query recursively.... .... 1... .... = Recursion available: Server can do recursive queries #服務支持遞歸查詢.... .... .0.. .... = Z: reserved (0).... .... ..0. .... = Answer authenticated: Answer/authority portion was not authenticated by the server.... .... ...0 .... = Non-authenticated data: Unacceptable.... .... .... 0000 = Reply code: No error (0)Questions: 1Answer RRs: 2Authority RRs: 5Additional RRs: 6Querieswww.a.shifen.com: type A, class INName: www.a.shifen.com[Name Length: 16][Label Count: 4]Type: A (Host Address) (1)Class: IN (0x0001)Answerswww.a.shifen.com: type A, class IN, addr 180.101.49.12www.a.shifen.com: type A, class IN, addr 180.101.49.11Authoritative nameserversa.shifen.com: type NS, class IN, ns ns3.a.shifen.coma.shifen.com: type NS, class IN, ns ns4.a.shifen.coma.shifen.com: type NS, class IN, ns ns5.a.shifen.coma.shifen.com: type NS, class IN, ns ns1.a.shifen.coma.shifen.com: type NS, class IN, ns ns2.a.shifen.comAdditional recordsns1.a.shifen.com: type A, class IN, addr 61.135.165.224ns2.a.shifen.com: type A, class IN, addr 220.181.33.32ns3.a.shifen.com: type A, class IN, addr 112.80.255.253ns4.a.shifen.com: type A, class IN, addr 14.215.177.229ns5.a.shifen.com: type A, class IN, addr 180.76.76.95<Root>: type OPT[Request In: 5][Time: 0.013373576 seconds]總結
以上是生活随笔為你收集整理的DNS抓包分析--wireshark的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: DHCP数据抓包分析--wireshar
- 下一篇: 【操作系统】分段内存管理