DHCP Debugging and Handy TCPdump filters

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

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末嫩实,一起剝皮案震驚了整個濱河市莽鸿,隨后出現(xiàn)的幾起案子吏恭,更是在濱河造成了極大的恐慌育灸,老刑警劉巖,帶你破解...
    沈念sama閱讀 217,826評論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件屎篱,死亡現(xiàn)場離奇詭異匆绣,居然都是意外死亡榜跌,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,968評論 3 395
  • 文/潘曉璐 我一進店門碧库,熙熙樓的掌柜王于貴愁眉苦臉地迎上來柜与,“玉大人,你說我怎么就攤上這事嵌灰∨埃” “怎么了?”我有些...
    開封第一講書人閱讀 164,234評論 0 354
  • 文/不壞的土叔 我叫張陵沽瞭,是天一觀的道長迁匠。 經常有香客問我,道長驹溃,這世上最難降的妖魔是什么城丧? 我笑而不...
    開封第一講書人閱讀 58,562評論 1 293
  • 正文 為了忘掉前任,我火速辦了婚禮吠架,結果婚禮上芙贫,老公的妹妹穿的比我還像新娘。我一直安慰自己傍药,他們只是感情好磺平,可當我...
    茶點故事閱讀 67,611評論 6 392
  • 文/花漫 我一把揭開白布魂仍。 她就那樣靜靜地躺著,像睡著了一般拣挪。 火紅的嫁衣襯著肌膚如雪擦酌。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,482評論 1 302
  • 那天菠劝,我揣著相機與錄音赊舶,去河邊找鬼。 笑死赶诊,一個胖子當著我的面吹牛笼平,可吹牛的內容都是我干的。 我是一名探鬼主播舔痪,決...
    沈念sama閱讀 40,271評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼寓调,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了锄码?” 一聲冷哼從身側響起夺英,我...
    開封第一講書人閱讀 39,166評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎滋捶,沒想到半個月后痛悯,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經...
    沈念sama閱讀 45,608評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡重窟,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 37,814評論 3 336
  • 正文 我和宋清朗相戀三年载萌,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片亲族。...
    茶點故事閱讀 39,926評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡炒考,死狀恐怖,靈堂內的尸體忽然破棺而出霎迫,到底是詐尸還是另有隱情斋枢,我是刑警寧澤,帶...
    沈念sama閱讀 35,644評論 5 346
  • 正文 年R本政府宣布知给,位于F島的核電站瓤帚,受9級特大地震影響,放射性物質發(fā)生泄漏涩赢。R本人自食惡果不足惜戈次,卻給世界環(huán)境...
    茶點故事閱讀 41,249評論 3 329
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望筒扒。 院中可真熱鬧怯邪,春花似錦、人聲如沸花墩。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,866評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至和泌,卻和暖如春村缸,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背武氓。 一陣腳步聲響...
    開封第一講書人閱讀 32,991評論 1 269
  • 我被黑心中介騙來泰國打工梯皿, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人县恕。 一個月前我還...
    沈念sama閱讀 48,063評論 3 370
  • 正文 我出身青樓东羹,卻偏偏與公主長得像,于是被迫代替她去往敵國和親弱睦。 傳聞我的和親對象是個殘疾皇子百姓,可洞房花燭夜當晚...
    茶點故事閱讀 44,871評論 2 354

推薦閱讀更多精彩內容