Managing vSphere Network From Command Line


Managing vSphere Standard Switch

Esxcli network vswitch command is used to do the networking configuration of a vswitch (Standard or vDS). The available namespace with this command are: standard and dvs as shown below

CLN-1

To list all Standard vSwitch present on the Esxi host

# esxcli network vswitch standard list

CLN-2

Add Remove vSphere Standard Switch

We can add/remove new standard switches or create a new portgroup in vswitch or associate uplinks to vswitch using the command

# esxcli network vswitch standard

The namespaces associated with the above command as shown below

CLN-3

CLN-4

Adding a new vSwitch to Esxi host

# esxcli network vswitch standard add –v=Name of vSwitch

Example:

# esxcli network vswitch standard add –v=vSwitch5

Adding a new vswitch with specific number of ports

# esxcli network vswitch standard add –v=vSwitch5  – -ports=256

CLN-5

Note: By default when a vSwitch is created it is created with 128 ports

Configuring Port Group on Standard Switches

Port groups are configured on vSwitch using the command

# esxcli network vswitch standard portgroup

The associated namespace with this command are as shown below:

CLN-6

Create a new portgroup in a standard vswitch

The following command is used to create a new portgroup on a standard vSwitch

# esxcli network vswitch standard portgroup add –p= name of port group  –v= Name of vSwitch

Example:

# esxcli network vswitch standard portgroup add –p=”FT NW”  –v=vSwitch6

CLN-7

Removing a portgroup from a vSwitch

Below command will delete a portgroup from a standard vswitch

# esxcli network vswitch standard portgroup remove –p=”FT NW”  –v=vSwitch1

CLN-7_2

Configuring CDP on Standard switches

Configuring CDP settings or MTU on a standard vswitch is done using the command :

# esxcli network vswitch standard set

CLN-8

To enable CDP on a vswitch

# esxcli network vswitch standard set  –c= cdp mode –v=vSwitch name

The accepted values for CDP is listen, advertise and both

Example:

# esxcli network vswitch standard set  –c=listen –v=vSwitch5

To disable CDP on a vswitch

# esxcli network vswitch standard set  –c=down –v=vSwitch5

CLN-9

Configuring uplinks for Standard vSwitch

The command used to add/remove uplinks to a standard vSwitch is

# esxcli network vswitch standard uplink

CLN-10

Adding an uplink to an existing vSwitch

# esxcli network vswitch standard uplink add –u=uplink name –v=vswitch name

Example

# esxcli network vswitch standard uplink add -u=vmnic1 -v=vSwitch1

The above command will add a new uplink vmnic1 to the vswitch1

Removing an existing uplink from a vSwitch

# esxcli network vswitch standard uplink remove -u=vmnic1 -v=vSwitch1

CLN-11

Setting Failover/Security/Traffic shaping policy configuration on a standard vSwitch

The command used to configure the policies on a standard vswitch is

# esxcli network vswitch standard policy

The available namespace with this command are shown below

CLN-12

Checking the configured policy (Failover/Security/Traffic Shaping) on a standard vSwitch

For e.g: command used to check the failover settings on a vSwitch are

# esxcli network vswitch standard policy failover -v vSwitch_name

similarly we can check security settings and traffic shaping settings on a vswitch

CLN-14

Configuring failover policy

To set failover settings on a vswitch the command used is

# esxcli network standard vswitch policy failover set

CLN-13

set command is used to apply the configuration settings available under failover policy

CLN-15

To check the failover policies on a Portgroup

get command is used to check the configured failover policy on a port group

# esxcli network vswitch standard portgroup policy failover get –p “Name of the portgroup”

For E.g

# esxcli network vswitch standard portgroup policy failover get -p “Prod NW”

CLN-16

Configuring Security Policy on standard vSwitch

The command used to set security policy on a vSwitch is

# esxcli network vswitch standard policy security

and the available namespace are “set and get”

CLN-17

set command is used to apply the settings available under security option like forged transmit or allowing promiscuous mode

CLN-18

To Set Traffic Shaping Policy

# esxcli network vswitch standard policy shaping set

The associated namespace are as follows

CLN-18_2

To list all the NICS present in Esxi host

The command used to see all the vmnics present on an Esxi host and their associated properties like link status, duplex speed, MTU value and Mac Address etc is

# esxcli network nic list

CLN-19

To check properties of a single vmknic

# esxcli network nic get -n vmnic1

CLN-20

For troubleshooting purposes, you can view statistics for a given NIC by running:

# esxcli network nic stats get -n vmnic1

CLN-21

The command used for performing operations on a single vmnic is

# esxcli network nic

The associated namespace are

CLN-22

Shutdown a vmnic

To shutdown vmnic on your Esxi host the command is

# esxcli network nic down –n=vmnic_name

CLN-23

After running the above command verify from your vCenter server console whether nic is disconnected or not

CLN-24

To reconnect a vmnic

The command used for bringing up a vmnic again is

# esxcli network nic up –n=vmnic_name

CLN-25

Checking TCP Segmentation offload and Checksum offload settings of vmnics

TCP segmentation offload and checksum offload are the techniques of network optimization where some of the network related tasks are offloaded to cpu of physical adapter. Not all the adapters support this feature but if it is supporting then we should enable it to get the most out of our physical adapters

The commands used for this purpose are:

# esxcli network nic tso get

# esxcli network nic cso get

CLN-26

CLN-27

Checking DNS server settings, Routing Table, ARP table and firewall settings

The parent command used for all these purpose is:

# esxcli network ip

The associated namespace are as follows:

CLN-28

Checking the ARP table of your Esxi host

The command used for this purpose is

# esxcli network ip neighbor list

CLN-29

DNS server settings

The parent command for DNS related settings is

# esxcli network ip dns server

And the associated namespace are:

CLN-30

List all the DNS servers configured on your Esxi host

# esxcli network ip dns server list

CLN-31

Configuring and Modifying Routing Table of your Esxi host

The parent command used for configuring routing table is

# esxcli network ip route

The associated namespaces are shown as below:

CLN-32

Checking the current status of routing table of your Esxi host

# esxcli network ip route ipv4 list

CLN-33

To add a new route to your Esxi host

The command to add a new route in your host is

# esxcli network ip route ipv4 add –n=network_add –g=gateway address

CLN-34

Configuring Esxi firewall settings

The parent command used for configuring firewall related settings is

# esxcli network firewall

Associated namespace are as follows:

CLN-35

CLN-36

To check the current firewall settings

# esxcli network firewall ruleset list

This command will list what are the services that are allowed/not allowed to pass through Esxi firewall

CLN-37

For exploring more command line options follow the below links:

vSphere Command-Line Interface Reference

Configuring vSwitch or vNetwork Distributed Switch from the command line

Hit Like and share this post on social media if the above post is informational to you. Happy Learning!!!

About Alex Hunt

Hi All I am Manish Kumar Jha aka Alex Hunt. I am currently working in VMware Software India Pvt Ltd as Operations System Engineer (vCloud Air Operations). I have around 5 Years of IT experience and have exposure on VMware vSphere, vCloud Director, RHEL and modern data center technologies like Cisco UCS and Cisco Nexus 1000v and NSX. If you find any post informational to you please press like and share it across social media and leave your comments if you want to discuss further on any post. Disclaimer: All the information on this website is published in good faith and for general information purpose only. I don’t make any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information you find on this blog is strictly at your own risk. The Views and opinions published on this blog are my own and not the opinions of my employer or any of the vendors of the product discussed.
This entry was posted in Vmware. Bookmark the permalink.

3 Responses to Managing vSphere Network From Command Line

  1. nithinkotian says:

    Thank you so much for the information and also looking info for vmware logs review

    Thanks, Nithin Kotian

    Like

  2. Pingback: Configuring Port Binding Using CLI | Go Virtual.

  3. I have read so many articles or reviews on the topic of the blogger lovers however this
    post is truly a nice piece of writing, keep it up.

    Like

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