11
8

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 5 years have passed since last update.

ARP をパケットキャプチャしてみる

Last updated at Posted at 2018-11-18

TL;DR

ARP の様子を Wireshark で眺めた。

検証概要

  • 互いに相手の MAC アドレスを知らない、同一リンク上の 2 つのホスト host A, host B を調達。
  • host A から host B に対して ping を打つ。
  • このときに流れる ARP 要求/応答パケットを tcpdump で取得。
  • これらのパケットを Wireshark で解析。
  • 「ARP を利用して host A が host B の MAC アドレスを知る様子」をパケットキャプチャで見てみる。

検証

ホストを調達する

192.168.1.0/24 のセグメントに 2 つのホストを立てます。プライベート IP アドレスは以下の通り。

host A host B
192.168.1.125 192.168.1.150

host A は host B の MAC アドレスを学習済みのようですが、検証のためにこの学習情報を削除します。

[ec2-user@ip-192-168-1-125 ~]$ arp
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.1.150            ether   06:6c:c2:38:da:6a   C                     eth0
gateway                  ether   06:85:cc:0c:f0:16   C                     eth0
169.254.169.254          ether   06:85:cc:0c:f0:16   C                     eth0
[ec2-user@ip-192-168-1-125 ~]$ sudo arp -d 192.168.1.150
[ec2-user@ip-192-168-1-125 ~]$ arp
Address                  HWtype  HWaddress           Flags Mask            Iface
gateway                  ether   06:85:cc:0c:f0:16   C                     eth0
169.254.169.254          ether   06:85:cc:0c:f0:16   C                     eth0
[ec2-user@ip-192-168-1-125 ~]$ 

今回の検証では ping 実行時に流れる ARP パケットを解析しようと思うので、icmp ポートの穴開けも行います。

tcpdump を仕込む

試しにオプション指定なしで tcpdump を実行したところ、尋常じゃない量のパケットが流れてきて辛かったので、適当にフィルタをつけます。

Wireshark で解析したいので、ファイル出力オプションもつけて実行します。

[ec2-user@ip-192-168-1-125 ~]$ sudo tcpdump icmp or arp net 192.168.1.0 mask 255.255.255.0 -s 0 -w /tmp/pcap
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes

パケットを流して取得する

別のターミナルにて、 host A から host B に対して ping を打ちます。

[ec2-user@ip-192-168-1-125 ~]$ ping 192.168.1.150
PING 192.168.1.150 (192.168.1.150) 56(84) bytes of data.
64 bytes from 192.168.1.150: icmp_seq=1 ttl=255 time=0.656 ms
64 bytes from 192.168.1.150: icmp_seq=2 ttl=255 time=0.516 ms
64 bytes from 192.168.1.150: icmp_seq=3 ttl=255 time=0.457 ms
64 bytes from 192.168.1.150: icmp_seq=4 ttl=255 time=0.446 ms
64 bytes from 192.168.1.150: icmp_seq=5 ttl=255 time=0.475 ms
64 bytes from 192.168.1.150: icmp_seq=6 ttl=255 time=0.473 ms
^C
--- 192.168.1.150 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5121ms
rtt min/avg/max/mdev = 0.446/0.503/0.656/0.077 ms
[ec2-user@ip-192-168-1-125 ~]$ 

Wireshark で解析する

取得したパケットファイルをローカルに持ち帰り、 Wireshark で開きます。

1.png

パッと見ただけで、以下の流れがわかります。

  1. host A がブロードキャストで host B の MAC アドレスを問い合わせる。
  2. host B が host A に対して、自身の MAC アドレスを応答する。
  3. 以降、ICMP 問い合わせ/回答を繰り返す。

参考文献

  • みやた ひろし (2017) 『パケットキャプチャの教科書』 SBクリエイティブ
11
8
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
11
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?