Host profiles and distributed switches provide excellent functionality for automation.
However a large number of sys admins may not have access to these features due to requiring a more expensive Enterprise plus licence of vSphere.
Even with a couple of hosts, the network configuration can become tedious in the GUI and in some cases (ie vMotion and case sensitive port group names), a typo can cause your solution extreme problems.
The below network script can be copied and pasted into a ssh session on a host which has just been installed with a management/service console port assumed on vswitch 0.
With a handful of hosts, this script can be edited to include specific IP information and saved for each host as part of a larger build script.
## Create Additional standard vSwitches ##
esxcfg-vswitch -a vSwitch1
esxcfg-vswitch -a vSwitch2##Link physical Nics to vSwitches ——–Confirm Nics ports on host
esxcfg-vswitch vSwitch1 -L vmnic2
esxcfg-vswitch vSwitch1 -L vmnic3
esxcfg-vswitch vSwitch2 -L vmnic4
esxcfg-vswitch vSwitch2 -L vmnic5## Create VMkernal port for vMotion ———- Unique IP config for host
esxcfg-vswitch -A "VMotion" vSwitch1
esxcfg-vmknic -a -i 192.168.90.12 -n 255.255.255.0 VMotion## Create port groups
esxcfg-vswitch vSwitch1 -A vMotion_vlan
esxcfg-vswitch vSwitch2 -A web_vlan
esxcfg-vswitch vSwitch2 -A app_vlan
esxcfg-vswitch vSwitch2 -A dmz_vlan
esxcfg-vswitch vSwitch2 -A UAT_vlan
esxcfg-vswitch vSwitch2 -A man_vlan
esxcfg-vswitch vSwitch2 -A Storage_vlan## Assign vlans
esxcfg-vswitch vSwitch1 -p vMotion_vlan -v 90
esxcfg-vswitch vSwitch2 -p web_vlan -v 30
esxcfg-vswitch vSwitch2 -p app_vlan -v 40
esxcfg-vswitch vSwitch2 -p dmz_vlan -v 50
esxcfg-vswitch vSwitch2 -p UAT_vlan -v 60
esxcfg-vswitch vSwitch2 -p man_vlan -v 70
esxcfg-vswitch vSwitch2 -p Storage_vlan -v 80