0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

tcpdump で SNMP のパケットをキャプチャする

Posted at

やりたいこと

tcpdump で SNMP のパケットをキャプチャし、その中身を確認したい。

  1. snmpget コマンドの通信
  2. snmpwalk コマンドの通信

それぞれの中身を確認する。

snmpget コマンドの通信を確認

発行するコマンド

マネージャ (192.0.2.58) 側で以下実行する。インターフェースは割り当てられた IPアドレスが所属するネットワークから判断して、適切なものを選択する。

tcpdump --direction inout --number -XX -vv -i eth0 port 161

クライアント (192.0.2.84) 側で以下実行する。

snmpget -v2c -c public 192.0.2.58 RFC1213-MIB::sysName.0

結果

1 で マネージャ (192.0.2.58) からクライアント (192.0.2.84) に GetRequest が送信された後、 2 で GetResponse が返っていることがわかる。

# tcpdump --direction inout --number -XX -vv -i eth0 port 161
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
    1  15:49:17.177040 IP (tos 0x0, ttl 63, id 22680, offset 0, flags [DF], proto UDP (17), length 71)
    192.0.2.84.58061 > 192.0.2.58.snmp: [udp sum ok]  { SNMPv2c { GetRequest(28) R=833053958  system.sysName.0 } }

    2  15:49:17.178997 IP (tos 0x0, ttl 63, id 56472, offset 0, flags [DF], proto UDP (17), length 83)
    192.0.2.58.snmp > 192.0.2.84.58061: [bad udp cksum 0x9c0c -> 0x3157!]  { SNMPv2c { GetResponse(40) R=833053958  system.sysName.0="76e6e9432f5d" } }
^C
2 packets captured
3 packets received by filter
0 packets dropped by kernel

snmpwalk コマンドの通信を確認

発行するコマンド

マネージャ (192.0.2.58) 側で以下実行する。インターフェースは割り当てられた IPアドレスが所属するネットワークから判断して、適切なものを選択する。

tcpdump --direction inout --number -XX -vv -i eth0 port 161

クライアント (192.0.2.84) 側で以下実行する。

snmpwalk -v2c -c public 192.0.2.58 RFC1213-MIB::sysName.0

結果

snmpwalk の場合は、 1 で GetNextRequest が送信され 2 で結果が返ってきた後に、 GetRequest を送信していることがわかる。

GetNextRequest で「結果がないよ」というレスポンスが返ってくるまでこれを繰り返すことによって、指定した OID 配下の値をすべて取得する。

# tcpdump --direction inout --number -XX -vv -i eth0 port 161
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
    1  15:48:14.970815 IP (tos 0x0, ttl 63, id 22669, offset 0, flags [DF], proto UDP (17), length 71)
    192.0.2.84.58109 > 192.0.2.58.snmp: [udp sum ok]  { SNMPv2c { GetNextRequest(28) R=1950637118  system.sysName.0 } }

    2  15:48:14.972005 IP (tos 0x0, ttl 63, id 42196, offset 0, flags [DF], proto UDP (17), length 78)
    192.0.2.58.snmp > 192.0.2.84.58109: [bad udp cksum 0x9c07 -> 0xbeda!]  { SNMPv2c { GetResponse(35) R=1950637118  system.sysLocation.0="unknown" } }

    3  15:48:14.976897 IP (tos 0x0, ttl 63, id 22670, offset 0, flags [DF], proto UDP (17), length 71)
    192.0.2.84.58109 > 192.0.2.58.snmp: [udp sum ok]  { SNMPv2c { GetRequest(28) R=1950637119  system.sysName.0 } }

    4  15:48:14.976991 IP (tos 0x0, ttl 63, id 42198, offset 0, flags [DF], proto UDP (17), length 83)
    192.0.2.58.snmp > 192.0.2.84.58109: [bad udp cksum 0x9c0c -> 0x5aed!]  { SNMPv2c { GetResponse(40) R=1950637119  system.sysName.0="76e6e9432f5d" } }

^C
4 packets captured
4 packets received by filter
0 packets dropped by kernel
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?