VMware ESXiのルーティングを設定するコマンド「esxcfg-route」についてのリファレンスを記述する。 まずは、VMWare ESXi 5.5のhelpから。
shell~ # esxcfg-route -h esxcfg-route <options> [<network> <gateway>] | <default gateway> <network> can be specified in 3 ways: * As a single argument in <IP>/<Mask> format * Or as a <IP> <Netmask> pair. * Or as 'default' -a|--add Add route to the VMkernel, requires <network> (described above) and gateway IP address -d|--del Delete route from the VMkernel. Requires <network> (described above) -l|--list List configured routes for the VMkernel -n|--neighbor-list Show Neighbor Cache entries for the VMkernel -f|--family <V4> or <V6> Address family to work on. Defaults to V4. -N|--netstack Netstack Instance -r|--restore Restore route setting to configured values on system start. (INTERNAL USE ONLY) -h|--help Show this message. If no options are specified then it will print the default IPv4 gateway. The default IPv4 gateway can be set directly as : esxcfg-route <gateway> Examples: To add a route to 192.168.100.0 network through 192.168.0.1 esxcfg-route -a 192.168.100.0/24 192.168.0.1 or esxcfg-route -a 192.168.100.0 255.255.255.0 192.168.0.1 To set the VMkernel default gateway of 192.168.0.1 esxcfg-route 192.168.0.1 or esxcfg-route -a default 192.168.0.1 To delete a 192.168.100.0 route from the VMkernel: esxcfg-route -d 192.168.100.0/24 192.168.0.1 To view the IPv4 ARP table: esxcfg-route -n To add a route to 2001:10:20:253::/64 network through 2001:10:20:253::1 esxcfg-route -f V6 -a 2001:10:20:253::/64 2001:10:20:253::1 To set the VMkernel default gateway of 2001:10:20:253::1 esxcfg-route -f V6 -a default 2001:10:20:253::1 To delete a 2001:10:20:253:: route from the VMkernel: esxcfg-route -f V6 -d 2001:10:20:253::/64 2001:10:20:253::1 To view the IPv6 Neighbor cache: esxcfg-route -f V6 -n
まぁ、ルーティングを設定するコマンドというだけあって、基本的に使うのってスタティックルートを設定するときくらいしか使わないと思うけど… 以下によく使う構文の例を記述する。
ルーティングの設定を確認する
以下のコマンドを実行することで、現在のルート設定を確認する。
shell~ # esxcfg-route -l VMkernel Routes: Network Netmask Gateway Interface 192.168.0.0 255.255.255.0 Local Subnet vmk0 default 0.0.0.0 192.168.0.1 vmk0
スタティックルートを追加する
以下のコマンドで、ESXiにスタティックルートを追加する。
shell~ # esxcfg-route -a 192.168.100.0/24 192.168.0.1 Adding static route 192.168.100.0/24 to VMkernel ~ # ~ # esxcfg-route -l VMkernel Routes: Network Netmask Gateway Interface 192.168.0.0 255.255.255.0 Local Subnet vmk0 192.168.100.0 255.255.255.0 192.168.0.1 vmk0 default 0.0.0.0 192.168.0.1 vmk0
ルート設定を削除する
以下のコマンドで、ESXiに設定されているルートを削除する。
shell~ # esxcfg-route -d 192.168.100.0/24 192.168.0.1 Deleting static route 192.168.100.0/24 from VMkernel ~ # ~ # esxcfg-route -l VMkernel Routes: Network Netmask Gateway Interface 192.168.0.0 255.255.255.0 Local Subnet vmk0 default 0.0.0.0 192.168.0.1 vmk0