VMware – Configuring VMware ESX Networking via CLI

Posted: May 26, 2010 in VMware

The majority of all the networking configuration you will need to perform on VMware ESX boils down to just a couple commands:

* esxcfg-vswitch: You will use this command to manipulate virtual switches (vSwitches) and port groups.
* esxcfg-nics: You will use this command to view (and potentially manipulate) the physical network interface cards (NICs) in the VMware ESX host.

Configuring VMware ESX networking boils down to a couple basic tasks:

1. Creating, configuring, and deleting vSwitches
2. Creating, configuring, and deleting port groups

I’ll start with creating, configuring, and deleting vSwitches.
Creating, Configuring, and Deleting vSwitches

You’ll primarily use the esxcfg-vswitch command for the majority of these tasks. Unless I specifically indicate otherwise, all the commands, parameters, and arguments are case-sensitive.

To create a vSwitch, use this command:

esxcfg-vswitch -a (vSwitch Name)

To link a physical NIC to a vSwitch—which is necessary in order for the vSwitch to pass traffic onto the physical network or to receive traffic from the physical network—use this command:

esxcfg-vswitch -L (Physical NIC) (vSwitch Name)

In the event you don’t have information on the physical NICs, you can use this command to list the physical NICs:

esxcfg-nics -l (lowercase L)

Conversely, if you need to unlink (remove) a physical NIC from a vSwitch, use this command:

esxcfg-vswitch -U (Physical NIC) (vSwitch Name)

To change the Maximum Transmission Unit (MTU) size on a vSwitch, use this command:

esxcfg-vswitch -m (MTU size) (vSwitch Name)

To delete a vSwitch, use this command:

esxcfg-vswitch -d (vSwitch Name)
Creating, Configuring, and Deleting Port Groups

As with virtual switches, the esxcfg-vswitch is the command you will use to work with port groups. Once again, unless I specifically indicate otherwise, all the commands, parameters, and arguments are case-sensitive.

To create a port group, use this command:

esxcfg-vswitch -A (Port Group Name) (vSwitch Name)

To set the VLAN ID for a port group, use this command:

esxcfg-vswitch -v (VLAN ID) -p (Port Group Name) (vSwitch Name)

To delete a port group, use this command:

esxcfg-vswitch -D (Port Group Name) (vSwitch Name)

To view the current list of vSwitches, port groups, and uplinks, use this command:

esxcfg-vswitch -l (lowercase L)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s