Configuring Port Binding Using CLI

In my last post Configuring Multipathing for Software iSCSI Using Port Binding we saw how to configure port binding and achieve multipathing for software iSCSI using GUI. In this post we will learn how to achieve the same using CLI.

I have posted an article Managing vSphere Network From Command Line sometime back and we will be using some commands to configure the network first. So lets begin.

1: Verify number of uplinks available on Esxi host

# esxcli network nic list

icli-1

2: List all Standard vSwitch along with associated uplink

# esxcli network vswitch standard list

icli-2

So we have 3 uplinks on Esxi host here: vmnic0,vmnic1 and vmnic2. Out of this vmnic0 is connected to vSwitch0 and providing the management network. We will create a new vswitch and use vmnic1 and vmnic2 as uplink to that vswitch.

3: Create a standard vSwitch by name iscsi-vSwitch

#  esxcli network vswitch standard add -v iscsi-vSwitch -P 256

4: Add vmnic1 and vmnic2 as uplink to “iscsi-vSwitch”

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

# esxcli network vswitch standard uplink add -u=vmnic2 -v=iscsi-vSwitch

icli-3

5: Make the uplinks as active

#  esxcli network vswitch standard policy failover set -a vmnic1,vmnic2 -v iscsi-vSwitch

6: Add 2 portgroups (iscsi-PG1 and iscsi-PG2) to iscsi-vSwitch

# esxcli network vswitch standard portgroup add -p=iscsi-PG1 -v=iscsi-vSwitch

# esxcli network vswitch standard portgroup add -p=iscsi-PG2 -v=iscsi-vSwitch

icli-4

7: Associate the uplinks with the correct portgroups

# esxcli network vswitch standard portgroup policy failover set -a vmnic1 -p iscsi-PG1

# esxcli network vswitch standard portgroup policy failover set -a vmnic2 -p iscsi-PG2

icli-5

8: Create the VMkernel interfaces and associate them with the portgroups iscsi-PG1 and iscsi-PG2

# esxcli network ip interface add -p iscsi-PG1 -i vmk1

# esxcli network ip interface add -p iscsi-PG2 -i vmk2

# esxcli network ip interface ipv4 set -i vmk1 -I 192.168.0.161 -N 255.255.255.0 -t static

# esxcli network ip interface ipv4 set -i vmk2 -I 192.168.0.162 -N 255.255.255.0 -t static

icli-6

9: Enable and Configure the iSCSI Software Adapter

# esxcli iscsi software set -e true

icli-7

10: Configure IP addresses of the iSCSI targets

# esxcli iscsi adapter discovery sendtarget add -a 192.168.0.90:3260 -A vmhba33

icli-8

Configure Port Binding

11: Bind the VMkernel network adapter to the iSCSI adapter

# esxcli iscsi networkportal add –nic vmk1 –adapter vmhba33

# esxcli iscsi networkportal add –nic vmk2 –adapter vmhba33
icli-11

Note: Binding details can be verified by using the following command:

# esxcli iscsi networkportal list –adapter vmhba33

iSCSI Re-login

If you have an already established iSCSI session before port binding configuration, you can remove the existing iSCSI sessions and log in again for the port binding configuration to take effect.

# esxcli iscsi session list –adapter vmhba33

icli-12

To remove existing iSCSI sessions, run the following command:

# esxcli iscsi session remove –adapter vmhba33

To enable sessions as per the current iSCSI configuration, run the following command:

# esxcli iscsi session add –adapter vmhba33

Verifying Multipath Configuration

After completing the port binding configuration and iSCSI adapter rescan, verify that iSCSI LUN’s are detected and displayed with the available paths.

For example, if you have bound two VMkernel network adapters to the iSCSI adapter, you will see two paths to each LUN connected to the iSCSI targets.

Before port binding, there is one path available to each target (T0, T1).

icli-9

After port binding two VMkernel network adapters to the iSCSI adapter, there are two paths available to each target (T0, T1).

icli-10

Configuring Round Robin

To load balance across paths you can configure the round robin multipath policy. This can be done in the ‘Manage Paths’ screen in the vSphere client, or by using esxcli:

# esxcli storage nmp satp set -s SATP_NAME -P VMW_PSP_RR

# esxcli storage nmp device list -d naa.600601602xxxxxxxxxxxxxxxx

I hope you enjoyed reading this post. Feel free to share this on social media if it is worth sharing. Be sociable 🙂

One thought on “Configuring Port Binding Using CLI

Leave a Reply