美文网首页
DHCP Debugging and Handy TCPdump

DHCP Debugging and Handy TCPdump

作者: ximitc | 来源:发表于2017-06-02 10:04 被阅读84次

Recently at $WORKwe’ve been having some strange issues with a particular XenVMnot gettingDHCP. Traditional (tail -f dhcpd.log) debugging hasn’t turned up much, other than the server is getting theDISCOVERbut not sending out anOFFER. I’ve turned to packet captures to try and track down the problem. Of course, this is wheretcpdumpandwiresharkcome into play. So I thought I’d share some of the filters that I’ve been using, and a few that I developed.

tcpdump filter forCDP(I should have this memorized by now) fromSWeidner:

tcpdump -nn -v -i eth0 -s 1500 -c 1'ether[20:2] == 0x2000'

Wireshark display filter for a specificDHCPclient (byMAC):

bootp.hw.mac_addr == 00:11:22:33:44:55

tcpdump filter to matchDHCPpackets including a specific ClientMACAddress:

tcpdump -i br0 -vvv -s 1500'((port 67 or port 68) and (udp[38:4] = 0x3e0ccf08))'

tcpdump only allows matching on a maximum of 4 bytes (octets), not the 6 bytes of aMACaddress. So, in the above example, we match the last 4 bytes (presumably the most unique) - our originalMACaddress was00:16:3e:0c:cf:08, so we match on3e0ccf08. Theudp[38:4]matches from the 38th octet after the start of theUDPheader (so the comparison starts on the 39th octet) and compares a chunk 4 octets long. TheUDPheaderis 8 octets long, followed immediately by theDHCPheader, and the ClientMACAddress field is composed of octets 29-35 of theDHCPheader. Therefore, 8 octets forUDPheader + 28 octets until ClientMACAddress + 2 octets offset (drop the first 2 octets ofMACaddress to allow a 4 octet comparison) = 38 (our total offset).

This can also be modified as a Wireshark display filter:

udp[38:4]==3e:0c:cf:08

Using the same logic, a tcpdump filter to capture packets sent by the client (DISCOVER,REQUEST,INFORM):

tcpdump -i br0 -vvv -s 1500'((port 67 or port 68) and (udp[8:1] = 0x1))'

Finally, a tcpdump filter forDHCPDISCOVERpackets (this makes the possibly flawed ass-umption that Option 53 will be the first option set:

udp[247:4] = 0x63350101

and a wireshark display filter:

udp[247:4]==63:35:01:01

And the same thing forDHCPREQUESTpackets:

udp[247:4] = 0x63350103

and a wireshark display filter:

udp[247:4]==63:35:01:03

相关文章

  • DHCP Debugging and Handy TCPdump

    Recently at $WORKwe’ve been having some strange issues wi...

  • IP获得抓包

    抓包验证 [root@baism dhcp]# tcpdump -nn -vvv -s 1500 -i ens33...

  • tcpdump抓DHCP包

    tcpdump -i eth0 -c 8 -s 0 -w /mnt/sdcard/dhcp.pcap 'udp a...

  • AE Handy Seamless Transitions3.3

    Handy Seamless Transitions简介: Handy Seamless Transitions是...

  • DHCP服务器

    DHCP服务 DHCP介绍 DHCP应用场景 DHCP工作原理 DHCP服务器部署 DHCP作用域 DHCP超级作...

  • tcpdump详细教程

    tcpdump tcpdump - dump traffic on a network tcpdump是一个用于截...

  • tcpdump 抓包

    tcpdump手册[https://www.tcpdump.org/manpages/tcpdump.1.html...

  • android抓包

    1、tcpdump链接:http://www.tcpdump.org/[http://www.tcpdump.or...

  • tcpdump命令

    1. tcpdump用途 抓包 2. tcpdump用法 tcpdump [option] expression...

  • dhcp

    1 DHCP概述 1.1 DHCP工作流程 发现阶段(DHCP DISCOVER) 即DHCP客户机寻找DHCP服...

网友评论

      本文标题:DHCP Debugging and Handy TCPdump

      本文链接:https://www.haomeiwen.com/subject/gmgyfxtx.html