今回は、vSwithに関しての操作ができるコマンド『esxcfg-vswitch』について記述する。 まずはESXi 5.5のヘルプの内容から。

shell
~ # esxcfg-vswitch -h esxcfg-vswitch [options] [vswitch[:ports]] -a|--add Add a new virtual switch. [--dvswitch --uuid=<16 hexadecimal digits> --impl-class=<implementation class>] Use --dvswitch to add a DVSwitch instead. (FOR INTERNAL USE ONLY). Use --uuid to specify the UUID for the DVSwitch (FOR INTERNAL USE ONLY). Use --impl-class to change implementation class from the default "etherswitch" class (FOR INTERNAL USE ONLY). -d|--delete Delete the virtual switch. [--dvswitch ] Use --dvswitch to delete a DVSwitch instead. (FOR INTERNAL USE ONLY). -l|--list List all the virtual switches. -L|--link=pnic Set pnic as an uplink for the vswitch. -U|--unlink=pnic Remove pnic from the uplinks for the vswitch. -R|--restore-uplinks Restore uplinks for all vswitches from config file. (FOR INTERNAL USE ONLY). -M|--add-pg-uplink=uplink Add an uplink to the list of uplinks for a portgroup -N|--del-pg-uplink=uplink Delete an uplink from the list of uplinks for a portgroup -P|--add-dvp-uplink=uplink Add an uplink to a DVPort on a DVSwitch. Must specify DVPort Id. -Q|--del-dvp-uplink=uplink Delete an uplink from a DVPort on a DVSwitch. Must specify DVPort Id. -V|--dvp=dvport Specify a DVPort Id for the operation. -p|--pg=portgroup Specify a portgroup for operation Use ALL to set VLAN IDs on all portgroups -v|--vlan=id Set vlan id for portgroup specified by -p 0 would disable the vlan -c|--check Check to see if a virtual switch exists. Program outputs a 1 if it exists, 0 otherwise. -A|--add-pg=name Add a new portgroup to the virtual switch. -D|--del-pg=name Delete the portgroup from the virtual switch. -C|--check-pg=name Check to see if a portgroup exists. Program outputs a 1 if it exists, 0 otherwise. -B|--set-cdp Set the CDP status for a given virtual switch. To set pass one of "down", "listen", "advertise", "both". -b|--get-cdp Print the current CDP setting for this switch. -X|--set-maxactive Set the max active uplinks for this switch. -x|--get-maxactive Print the max active uplinks for this switch. -m|--mtu=MTU Set MTU for the vswitch/DVSwitch. This affects all the nics attached on the vswitch. -r|--restore Restore all virtual switches from the configuration file (FOR INTERNAL USE ONLY). -h|--help Show this message.

後は、比較的よく使うであろう構文だけ例として記述していく。

管理vSwitchの一覧を表示させる

以下のコマンドを実行することで、現在vSphere ESXi上にあるvSwitchの一覧を表示させる事ができる。

shell
~ # esxcfg-vswitch -l Switch Name Num Ports Used Ports Configured Ports MTU Uplinks vSwitch0 1536 4 128 1500 vmnic0 PortGroup Name VLAN ID Used Ports Uplinks VM Network 0 0 vmnic0 Management Network 0 1 vmnic0

管理vSwitchを追加する

以下のコマンドでvSwitchを追加出来る。

shell
~ # esxcfg-vswitch -a vSwitch名

管理vSwitchを削除する

以下のコマンドでvSwitchを削除出来る。

shell
~ # esxcfg-vswitch -d vSwitch名

管理vSwitchに新しいポートグループを追加する

以下のコマンドで指定したvSwitchに新規のポートグループを作成し追加する。

shell
~ # esxcfg-vswitch -A 新しいポートグループ名 vSwitch名

管理vSwitchからポートグループを削除する

以下のコマンドで指定したvSwitchからポートグループを削除する。

shell
~ # esxcfg-vswitch -D ポートグループ名 vSwitch名

管理vSwitchにvmnic(物理NIC)を追加する

以下のコマンドで指定したvSwitchにvmnicを追加する

shell
~ # esxcfg-vswitch -L vmnic名 vSwitch名

管理vSwitchからvmnic(物理NIC)を削除する

以下のコマンドで指定したvSwitchからvmnicを削除する

shell
~ # esxcfg-vswitch -U vmnic名 vSwitch名

ESXi用の管理NICとして用いるための設定は、「esxcfg-vmknic」コマンドを用いる事で設定出来る。