vSphere

vSphere 5.5 の新機能紹介 ネットワーク1 (ホストレベルのパケットキャプチャ)

このBlogは、製品出荷前バイナリ及びマニュアルをベースに記載しています。出来る限り正確な情報をお伝えするよう努めておりますが、実際に製品に搭載される機能や表示と異なる可能性があります。あらかじめご了承の上ご利用下さい。
今回は先日発表されましたVMware vSphere 5.5 で追加されたネットワークの新機能のなかから、ホストレベルのパケットキャプチャの概要をご紹介します。vSphere 5.5 では、ホストレベルのパケットキャプチャ機能を新たに実装します。この機能によりトラブルシューティング時に必要となるパケットキャプチャにより詳細なオプションが提供されます。

■特徴
・ESXi ホスト上で、CLI からpktcap-uw コマンドでパケットキャプチャを実施します。vSphere Client、Web Client からは使用できません。
・標準仮想スイッチ(vSS) 及び分散仮想スイッチ(vDS)上のトラフィックをキャプチャすることが可能です。
・Uplink, 仮想スイッチポート, vmk NIC で発生するトラフィックに対し、キャプチャするポイントを指定することが可能です。

■オペレーション
・ヘルプを表示
# pktcap-uw –help
・各種オプション
-p, –port <Socket PORT>  Specify the port number of vsocket server.
-o, –outfile <FILE>  Specify the file name to dump the packets. If unset, output to console by default
-P, –ng (only working with ‘-o’) Using the pcapng format to dump into the file.
–console (by default if without ‘-o’) Output the captured packet info to console.
-s, –snaplen <length> Only capture the first <length> packet buffer.
-c, –count <NUMBER> How many count packets to capture.
-h Print this help.
-A, –availpoints List all capture points supported.
-F List all dynamic capture point functions supported.
–capture <capture point> Specify the capture point. Use ‘-A’ to get the list. If not specified, will select the capture point by –dir and –stage setting
・ポートオプション
–switchport <port ID> (Specify the switch port by ID)
–lifID <lif ID> (Specify the logical interface id of VDR port)
–vmk <vmk NIC> (Specify the switch port by vmk NIC)
–uplink <vmnic> (Specify the switch port by vmnic)
–switchportを使用する場合、esxtopの n オプションで対象のポートIDを確認します。

・キャプチャポイント
pktcap-uw –A コマンドで、サポートされるキャプチャポイントを表示します。キャプチャポイントは、–capture で指定することができます。キャプチャポイントの中にはポートオプションの指定やキャプチャポイントオプションの指定が必須のものがあります。なお、Dropを指定することで、ESXi でドロップしたパケットを収集することが可能です。
# pktcap-uw -A
Supported capture points:
1: Dynamic — The dynamic inserted runtime capture point.
2: UplinkRcv — The function that receives packets from uplink dev
3: UplinkSnd — Function to Tx packets on uplink
4: Vmxnet3Tx — Function in vnic backend to Tx packets from guest
5: Vmxnet3Rx — Function in vnic backend to Rx packets to guest
6: PortInput — Port_Input function of any given port
7: IOChain — The virtual switch port iochain capture point.
8: EtherswitchDispath — Function that receives packets for switch
9: EtherswitchOutput — Function that sends out packets, from switch
10: PortOutput — Port_Output function of any given port
11: TcpipDispatch — Tcpip Dispatch function
12: PreDVFilter — The DVFIlter capture point
13: PostDVFilter — The DVFilter capture point
14: Drop — Dropped Packets capture point
15: VdrRxLeaf — The Leaf Rx IOChain for VDR
16: VdrTxLeaf — The Leaf Tx IOChain for VDR
17: VdrRxTerminal — Terminal Rx IOChain for VDR
18: VdrTxTerminal — Terminal Tx IOChain for VDR
19: PktFree — Packets freeing point
・キャプチャポイントオプション
Dynamic, IOChain, TcpipDispatch といったキャプチャポイントでは、パラメータを追加し対象を指定します。
-f [module name.]<function name> The function name. The Default module name is ‘vmkernel’. (for ‘Dynamic’, ‘IOChain’ and ‘TcpipDispatch’ capture points)
–dvfilter <filter name> Specify the dvfilter name for DVFilter related points
・キャプチャポイントの簡易選択
–capture でキャプチャポイントを指定しない場合、トラフィックの方向(送信もしくは受信)を–dirで指定し、キャプチャするポイントを–stage で指定することができます。これらのオプションは、–switchport, –vmk, –uplink といったポートオプションと合わせて使用します。なお1つのモニタセッションで、送受信両方向のトラフィックの取得はできません。
–dir <0|1> (for –switchport, –vmk, –uplink) The direction of flow: 0- Rx (Default), 1- Tx
–stage <0|1> (for –switchport, –vmk, –uplink, –dvfilter) The stage at which to capture: 0- Pre: before, 1- Post:After
–dir で指定する際、トラフィックは仮想スイッチを基点とした方向となります。そのため–dir 1 でTx(送信)を指定した場合でも、ポートオプションによってキャプチャできる通信の方向が異なります。例えばポートオプションで、–uplink を指定した場合はホストの外部に向かって出て行くトラフィックとなり、–switchport 及び–vmk を指定した場合は、外部から入ってくるトラフィックをキャプチャすることになります。


・フィルターオプション
フィルターを適用することで特定のトラフィックを収集できます。
–srcmac <xx:xx:xx:xx:xx> (The Ethernet source MAC address)
–dstmac <xx:xx:xx:xx:xx> (The Ethernet destination MAC address)
–mac <xx:xx:xx:xx:xx> (The Ethernet MAC address(src or dst))
–ethtype 0x<ETHTYPE> (The Ethernet type. HEX format)
–vlan <VLANID> (The Ethernet VLAN ID)
–srcip <x.x.x.x[/<range>]> (The source IP address)
–dstip <x.x.x.x[/<range>]> (The destination IP address)
–ip <x.x.x.x> (The IP address(src or dst))
–proto 0x<IPPROTYPE> (The IP protocol)
–srcport <SRCPORT> (The TCP source port)
–dstport <DSTPORT> (The TCP destination port)
–tcpport <PORT> (The TCP port(src or dst))
–vxlan <vxlan id> (The vxlan id of flow)

■実行例
それぞれ、vmk NIC、仮想スイッチのポート、Uplink で取得する例を以下に記載します。
1. vmk NICで取得
vmk1 から外部に送信(仮想スイッチから見ると受信)する60個のパケットをキャプチャしファイルに保存する例
# pktcap-uw –vmk vmk1 –dir 0 -c 60 -o test01.pcap
2. 仮想スイッチのポートで取得
仮想スイッチのポートで受信する宛先172.16.161.234のパケットをキャプチャしファイルに保存する例(Port ID XXXXXXXX は、esxtop のn オプションで確認を行います)
# pktcap-uw –switchport XXXXXXXX –dir 0 –dstip 172.16.161.234 -o test02.pcap
3. Uplink で取得
vmnic1 から外部に送信するVXLAN カプセル化前のパケットをキャプチャしファイルに保存する例
# pktcap-uw –uplink vmnic1 –dir 1 –stage 0 -o test03.pcap
4. Uplink で取得
vmnic1 から外部に送信するVXLAN カプセル化後のパケットをキャプチャしファイルに保存する例
# pktcap-uw –uplink vmnic1 –dir 1 –stage 1 -o test04.pcap

■キャプチャしたパケットの確認
キャプチャしたパケットをローカルにダウンロードし、WireShark 等のネットワークプロトコルアナライザで中身の確認を行うことができます。SCP 等でESXi からキャプチャしたファイルをダウンロードします。

ダウンロードしたファイルをWireShark で開きます。下記のケースでは、実行例3(Uplink で取得)でキャプチャしたICMP パケットが確認できます。

下記のケースでは、実行例4(Uplink で取得)でキャプチャした、VXLAN でカプセル化されたパケットが確認できます。VXLAN でカプセル化されたパケットの中身を確認する際は、WireShark で「Decode As」を選択し、UDP Destination port 8472 をVXLAN でデコードします。(vSphere 5.5 のVXLAN 実装では、デフォルトでUDP port 8472 を使用します)

VXLAN ヘッダーを認識し、カプセル化されたオリジナルのパケット(ICMP)を確認できるようになります。

以上、vSphere 5.5 のホストレベルのパケットキャプチャの概要をご紹介いたしました。