Share
Embed
Transcript
14 slides
-
Copyright (C) 2019 Yahoo Japan Corporation. All Rights Reserved. 2019年5月17日
入江 正博 ESXi 上での VM IP 取得について -
Copyright (C) 2019 Yahoo Japan Corporation. All Rights Reserved. 自己紹介
2 入江 正博 @IrieMasahiro • ヤフー株式会社 プライベートクラウドチーム • VMUG インフラ仮想部会 • vExpert 2019 -
Copyright (C) 2019 Yahoo Japan Corporation. All Rights Reserved. 事の発端
3 • ESXi 上の VM の IP を社内の管理システ ムに連携させたい • 取れる VM、取れない VM、変な VM … → 仕様を追っかけてみた -
Copyright (C) 2019 Yahoo Japan Corporation. All Rights Reserved. ESXi
上の VM IP 取得方法 4 • VMware Tools (open-vm-tools) • ARP packet Inspection -
Copyright (C) 2019 Yahoo Japan Corporation. All Rights Reserved. VMware
Tools での取得 6 • open-vm-tools が内部で getifaddrs() を発行 • getifaddrs() の結果にフィルタかけて Backdoor IF 経由で ESXi へ • 上限数を超えると切り捨て • 16 NICs / 2048 IPs → IP は ESXi で もフィルタしている? • open-vm-tools でハードコーディング https://github.com/vmware/open-vm-tools/blob/master/open-vm-tools/lib/guestRpc/nicinfo.x#L36-L42 -
Copyright (C) 2019 Yahoo Japan Corporation. All Rights Reserved. 仮想
IF と VMware Tools 8 • 取得 NIC は getifaddrs() 依存 • 仮想 IF と相性が悪い時代があった • veth* で eth* が漏れる場合が • 10.2.0 で仮想 IF の prefix を見て除外す るように • 現在はデフォルトでdocker*, veth*, virbr* が除外に • tools.conf で制御可能 • https://github.com/vmware/open-vm-tools/wiki/Configuration -
Copyright (C) 2019 Yahoo Japan Corporation. All Rights Reserved. ARP
packet Inspection 9 vSwitch (vSS/vDS) 上で ARP パケットを拾い、そ の内容から IP を取得する • ESXi で設定が必要 • VM 側ではあれこれ不要 • 1Port に対して 1IP、複数 IP は後勝ち • ARP パケットが流れていないと値が取れない • vMotion が起こると一時的に情報消失 • Packer やっている人にはおなじみ? # esxcli system settings advanced set -o /Net/GuestIPHack -i 1 https://blogs.vmware.com/vsphere/2013/01/network-troubleshooting-using-esxcli-5-1.html -
Copyright (C) 2019 Yahoo Japan Corporation. All Rights Reserved. IP
の取得手順 10 ・esxcli での取得に • World ID も esxcli から取得 # esxcli network vm port list --world-id=【VMのWorld ID】 # esxcli vm pocess list -
Copyright (C) 2019 Yahoo Japan Corporation. All Rights Reserved. IP
習得の実行例 11 # esxcli vm process list test-vm02 World ID: 2154074 Process ID: 0 VMX Cartel ID: 2154071 UUID: 42 0b 35 bb 3c 8f 64 09-64 86 bc ae 77 d8 8a 09 Display Name: test-vm02 Config File: /vmfs/volumes/5c8d2b8a-a7749b83-7deb-6c626de6caee/test-vm02/test-vm02.vmx # esxcli network vm port list --world-id=2154074 Port ID: 33554463 vSwitch: vSwitch0 Portgroup: VM Network DVPort ID: MAC Address: 00:50:56:8b:a7:20 IP Address: 192.168.0.128 Team Uplink: vmnic0 Uplink Port ID: 33554434 Active Filters: -
Copyright (C) 2019 Yahoo Japan Corporation. All Rights Reserved. govc
だと楽 12 • esxcli での取得は面倒… • ssh で ESXi にログインして実行 • World ID が vMotion で変わる • govc を使うと楽に取得できる • govmomi で実装された CLI ツール • govmomiに同梱 • vmomi 経由で esxcli 叩いている % govc vm.ip -esxcli -dc=【Datacenter名】 【VM名】 192.168.0.128 -
Copyright (C) 2019 Yahoo Japan Corporation. All Rights Reserved. まとめ
13 • VMware Tools • VM内での getifaddr() の結果を渡す • 仮想 IF がある VM は要注意 • ARP packet Inspection • vSwitch 上で ARP を拾う • ESXi 側で設定、VM 側は仕込み不要 • govc 経由だと esxcli(ssh) 不要