How To Configure ESXi Networking using ESXCLI-* Command Line – Part-II

 

 

vSphere_networking

In my last blog, we discussed in-detail about esxcfg-vswitch command line API and how multiple options (esxcfg-vswitch -h) provided by this API can be used to configure ESXi Networking.
From my personal experience with VMware Technologies and Its Field issues, I would recommend every vSphere admin to learn these commands & grasp it firmly in memory.
These commands would help you a lot while debugging and troubleshooting vSphere Networking issues.

Similar to esxcfg-*, vSphere has another Command Line API called “ESXCLI-*” which allows system admin or ESXi shell user to configure, manage & troubleshoot vSphere issues.

This API also has thousands of command options so it won’t be possible to explain everything in this blog.

In this article, we’re going to focus mainly on vSphere Networking related commands & we’ll be setting up basic ESXi Network configuration using ESXCLI-* commands.

 

HOW TO CONFIGURE ESXi NETWORKING USING ESXCLI-* COMMANDS

 

 

Step 1: Run the help command to understand which namespace you want to deal with:

 

esxcli network <press enter> or esxcli network -h

esxcli_network

Description:

This command will list out available namespaces which details can be retrieved further.

For ex:

This output shows that:

To retrieve any details about vSwitch then execute:

esxcli network vswitch

To retrieve any details about nic then execute:

esxcli network nic

 

Step 2: List All vSwitches Information Created on ESXi Host

esxcli network vswitch standard list

esxcli_network_vswitch_standard_list

Description:

This output explains that there is single vSwitch0 created on ESXi Host having Two Portgroups called “VM Network” & “Management Network”. It also explains that MTU is configured is 1500 Bytes and CDP mode configured on switch is “Listen Mode”.

So you might be think what is CDP & what does it mean by Listen Mode so let’s understand CDP before going further.

 

WHAT IS CDP

CDP stands for Cisco Discovery Protocol. Its Cisco Proprietary protocol which allows devices to share network information with their neighboring devices they are connected to.

 In ESXi environment, CDP helps VMware administrators to retrieve information like which port of the switch uplink is connected to, Switch IP, VLAN configuration, Software version, MTU configured on switch etc…

 

WHAT IS LISTEN MODE

VMware ESXi is capable of using the CDP protocol & it can be configured in three different modes as explained below:

Listen: In Listen Mode, the host will display information about the physical switch it is connected to but it will not send its own details to Physical switch. Host CDP information will not be available to Switch its connected to.

Advertise: In Advertise Mode, the Host will send CDP information to the Physical switch but will not display any information about the physical switch. This mode is opposite of the Listen Mode.

Both: In this Mode, the Host send/receives CDP information to Physical Switch.

By default, the CDP configuration is in Listen only Mode on Standard switches as well as Distributed Switches.

To view CDP status for vSwitch using esxcfg-* API

~ # esxcfg-vswitch -b vSwitch0

listen

 

 

Step 3: Create New VSWITCH

 

esxcli network vswitch standard add -P <No of Ports> -v <vSwitch_name>

esxcli_network_vswitch_standard_port_vswitchname

Description:

This output explains that a new vswitch called “TestvSwitch” created on ESXi Host with No Uplink and Portgroups created on it. This switch is configured with 150 ports, MTU size 1500 bytes and CDP mode is Listen (Default mode)

 

Step 4: Create New PORTGROUP on vSwitch

 

esxcli network vswitch standard portgroup add -p <PortGroup> -v <vSwitch_name>

esxcli_network_vswitch_standard_portgroup_vswitchname

Description:

This output shows that new TestPG portgroup created on TestvSwitch.

 

Step 5: Assign UPLINK to vSwitch

esxcli network vswitch standard uplink add -u <Uplink_Name > -v <vSwitch_Name>

esxcli_network_vswitch_standard_uplink_vswitchname

 

Description:

This output shows that vmnic2 is assigned as one of the Uplink to TestvSwitch.

 

Step 6: Assign VLAN To PortGroups

esxcli network vswitch standard portgroup set -p <Portgroup_Name> -v <VLAN_ID>

esxcli_network_vswitch_standard_portgroup_vlan

Description:

VLAN configuration doesn’t get populated in “esxcli network vswitch standard list” output so it can be verified through esxcfg-vswitch -l command output.
In Our scenario, it clearly shows that VLAN 100 configured on TestPG.

 

Step 7: Change MTU Size of vSwitch

esxcli network vswitch standard set -m <MTU_Size> -v <vSwitch_Name>

esxcli_network_vswitch_standard_MTU_vswitchname

Description:

This output shows that TestvSwitch configured with MTU Size 9000.

 

At this point, we have setup basic network configuration required for VMs to communicate with each other or external world.

 

Next Few Commands will be related to wiping out Networking Configuration

 

Step 8: Remove VLAN Configuration or Restore Default Configuration

 

esxcli network vswitch standard portgroup set -p <Portgroup_Name> -v 0

esxcli_network_vswitch_standard_portgroup_removevlan

Description:

VLAN Configuration can be wiped out or deleted by setting up VLAN ID back to 0.

 

Step 9: Restore MTU Size Back to Default Configuration

 

esxcli network vswitch standard set -m 1500 -v <vSwitch_Name>

 

esxcli_network_vswitch_standard_MTU1500_vswitchname

Description:

Setting MTU Size Back to 1500 remove Jumbo Frame Configuration and restore switch to default MTU size.

 

Step 10: Remove UPLINK From vSwitch

 

esxcli network vswitch standard uplink remove -u <Uplink_Name> -v <vSwitch_Name>

 

esxcli_network_vswitch_standard_remove_uplink_vswitchname

Description:

This command removes uplink vmnic2 from vSwitch which means none of the VMs or VMKNIC Traffic will be able to communicate to external world. Traffic will not go out of the vSwitch.

Just to remind you, in above mentioned configuration VMs running on TestvSwitch will still be able to talk to each other even though no Uplink assigned to TestvSwitch.

I am hoping you guys would definitely be knowing the reason for this.

 

Step 11: Remove PORTGROUPS From vSwitch

 

esxcli network vswitch standard portgroup remove -p <TestPG> -v <vSwitch_Name>

 

esxcli_network_vswitch_standard_remove_portgroup_vswitchname

Description:

This command deletes TestPG portgroup.

 

Step 12: Remove VSWITCH

 

esxcli network vswitch standard remove  -v <vSwitch_Name>

 

esxcli_network_vswitch_standard_remove_vswitch

 

I hope you guys might have got little familiar with ESXCLI Command line and have a better understanding on how to configure ESXi Networking using ESXCLI Commands.

 

If you guys like this Article then please rate it & share your feedback. Your Feedback is valuable for me to improvise myself as Blogger.

You May Also Interested In

govmlab on sabtwittergovmlab on sablinkedingovmlab on sabgooglegovmlab on sabfacebookgovmlab on sabemail
I am VMware Solution Architect with 10+ Years of enriching experience in Datacenter Virtualization Technologies, Storage Area Networks and Software Defined Datacenter, Networking and Storage.
I hold Numerous certification including RHCE, CCNA, VCP4.0, VCP5.1, VCP5.5, vCloud and EMC certification.
While spending countless hours exploring the product inside and out and learning everything about it, Eventually I discovered my passion for teaching and helping others learn from my knowledge and experience so turned to Trainer cum Blogger to educate every single person keen to learn Virtualization.

Leave a Reply