Creating five or more virtual port groups through the VI client can mean repeating the same work. If you prefer the command line, sign in to the Service Console and use the following commands.
Create a virtual port group:
Code1 line
1
esxcfg-vswitch -A NAME-TO-GIVE vSwitch0
Assign a specific VLAN to the port group:
Code1 line
1
esxcfg-vswitch -v VLANID -p PORTGROUP vSwitch0
With these two commands in a shell script, I created the same networking configuration on a dozen ESX servers:
esxcfg-vswitch [options] [vswitch[:ports]]
-a|--add Add a new virtual switch.
-d|--delete Delete the virtual switch.
-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.
-M|--add-pg-uplink Add an uplink to the list of uplinks for a portgroup
-N|--del-pg-uplink Delete an uplink from the list of uplinks for a portgroup
-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.
-m|--mtu=MTU Set MTU for the vswitch.
-r|--restore Restore all virtual switches from the configuration file
(FOR INTERNAL USE ONLY).
-h|--help Show this message.
Comments from the original WordPress site, kept read-only.
Walter
Thanks for this, it was a HUGE help!
Celia
My OS is ESXi 5.5 and is using web client to mange the host. I can list out the new portgroup by "esxcfg-vswitch -l" but I can't see the new port group from web client. I refresh the web client several times and it still get nothing. Please help.
Thanks for this, it was a HUGE help!
My OS is ESXi 5.5 and is using web client to mange the host. I can list out the new portgroup by "esxcfg-vswitch -l" but I can't see the new port group from web client. I refresh the web client several times and it still get nothing. Please help.