それマグで!

知識はカップより、マグでゆっくり頂きます。 takuya_1stのブログ

習慣に早くから配慮した者は、 おそらく人生の実りも大きい。

dhcpのリクエスト・レスポンスの応答を調べる dhcpdump

dhcp のパケットを見たい。

sudo tcpdump -i macvlan0 port 67 or port 68 -e -n

ただ、これだと凄く使いにくい。もっとわかりやすく見たい。

dhcpdump が便利。

tcpdump を使わずに dhcpdumpを使うともっと簡単にdhcpのパケットを追いかけることが出来る。専用コマンド便利ですね。

sudo apt install dhcpdump

利用例

sudo dhcpdump -i macvlan0
  TIME: 2023-01-18 17:36:40.745
    IP: 0.0.0.0 (52:54:0:60:2b:ac) > 255.255.255.255 (ff:ff:ff:ff:ff:ff)
    OP: 1 (BOOTPREQUEST)
 HTYPE: 1 (Ethernet)
  HLEN: 6
  HOPS: 0
   XID: 5d5415d9
  SECS: 1
 FLAGS: 0
CIADDR: 0.0.0.0
YIADDR: 0.0.0.0
SIADDR: 0.0.0.0
GIADDR: 0.0.0.0
CHADDR: 52:54:00:60:2b:ac:00:00:00:00:00:00:00:00:00:00
 SNAME: .
 FNAME: .
OPTION:  53 (  1) DHCP message type         1 (DHCPDISCOVER)
OPTION:  61 ( 19) Client-identifier         ff:56:50:4d:98:00:02:00:00:ab:11:e7:5f:9b:8b:d2:86:d0:a4
OPTION:  55 ( 11) Parameter Request List      1 (Subnet mask)
                          3 (Routers)
                         12 (Host name)
                         15 (Domainname)
                          6 (DNS server)
                         26 (Interface MTU)
                         33 (Static route)
                        121 (Classless Static Route)
                        119 (Domain Search)
                         42 (NTP servers)
                        120 (SIP Servers DHCP Option)

OPTION:  57 (  2) Maximum DHCP message size 576
OPTION:  12 (  6) Host name                 ubuntu
---------------------------------------------------------------------------

  TIME: 2023-01-18 17:36:43.761
    IP: 0.0.0.0 (52:54:0:60:2b:ac) > 255.255.255.255 (ff:ff:ff:ff:ff:ff)
    OP: 1 (BOOTPREQUEST)
 HTYPE: 1 (Ethernet)
  HLEN: 6
  HOPS: 0
   XID: 5d5415d9
  SECS: 3
 FLAGS: 0
CIADDR: 0.0.0.0
YIADDR: 0.0.0.0
SIADDR: 0.0.0.0
GIADDR: 0.0.0.0
CHADDR: 52:54:00:60:2b:ac:00:00:00:00:00:00:00:00:00:00
 SNAME: .
 FNAME: .
OPTION:  53 (  1) DHCP message type         3 (DHCPREQUEST)
OPTION:  61 ( 19) Client-identifier         ff:56:50:4d:98:00:02:00:00:ab:11:e7:5f:9b:8b:d2:86:d0:a4
OPTION:  55 ( 11) Parameter Request List      1 (Subnet mask)
                          3 (Routers)
                         12 (Host name)
                         15 (Domainname)
                          6 (DNS server)
                         26 (Interface MTU)
                         33 (Static route)
                        121 (Classless Static Route)
                        119 (Domain Search)
                         42 (NTP servers)
                        120 (SIP Servers DHCP Option)

OPTION:  57 (  2) Maximum DHCP message size 576
OPTION:  54 (  4) Server identifier         192.168.1.1
OPTION:  50 (  4) Request IP address        192.168.1.193
OPTION:  12 (  6) Host name                 ubuntu
---------------------------------------------------------------------------

参考資料

https://matoken.org/blog/2019/04/10/a-memo-to-capture-dhcp-packets/