How to configure vSwitch from CLI using esxcfg-vswitch command

If you need to change your vswitch and port group settings using the service console or SSH, esxcfg-vswitch is what you need to use.

A) List all virtual switches and the port group

[root@datahivehost1:~] esxcfg-vswitch -l
Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch0 5376 14 128 1500 vmnic0

PortGroup Name VLAN ID Used Ports Uplinks
VM_Management 888 6 vmnic0
VMVLAN1 1 3 vmnic0
vmotion 188 1 vmnic0
ManagementNetwork 888 1 vmnic0

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch_NFS 5376 4 1024 1500 vmnic3

PortGroup Name VLAN ID Used Ports Uplinks
DATA_LAN 0 0 vmnic3
NFS 567 1 vmnic3

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch_VM_Network 5376 1 1024 1500

PortGroup Name VLAN ID Used Ports Uplinks

DVS Name Num Ports Used Ports Configured Ports MTU Uplinks
DATAHIVEDSwitch 5376 17 512 9000 vmnic1,vmnic2

DVPort ID In Use Client
34 1 vmnic1
35 1 vmnic2
18 1 MK_WIN16-01.eth0
45 1 Hive_Sense02.eth2
21 1 MK_Desktop02.eth0
44 1 Hive_Sense01.eth2
68 1 Hive-NSX-Manager.eth0
22 1 MK_WIN_01.eth0
88 1 RHUI-Client01.eth0
86 1 CDS01.eth0
89 1 RHUI-RHEL8-01.eth0
84 1 Repostore.eth0
95 1 lab-svr-01.eth0
96 1 lab-svr-02.eth0

B) Create new Port Group on existing vSwitch

Command syntax:

esxcfg-vswitch –A <Port Group Name> <vSwitch Name>

[root@datahivehost1:~] esxcfg-vswitch -A testpg vSwitch_NFS

verify new port group

[root@datahivehost1:~] esxcfg-vswitch -l
Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch0 5376 14 128 1500 vmnic0

PortGroup Name VLAN ID Used Ports Uplinks
VM_Management 888 6 vmnic0
VMVLAN1 1 3 vmnic0
vmotion 188 1 vmnic0
ManagementNetwork 888 1 vmnic0

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch_NFS 5376 4 1024 1500 vmnic3

PortGroup Name VLAN ID Used Ports Uplinks
testpg 0 0 vmnic3
DATA_LAN 0 0 vmnic3
NFS 567 1 vmnic3

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch_VM_Network 5376 1 1024 1500

PortGroup Name VLAN ID Used Ports Uplinks

DVS Name Num Ports Used Ports Configured Ports MTU Uplinks
DATAHIVEDSwitch 5376 17 512 9000 vmnic1,vmnic2

DVPort ID In Use Client
34 1 vmnic1
35 1 vmnic2
18 1 MK_WIN16-01.eth0
45 1 Hive_Sense02.eth2
21 1 MK_Desktop02.eth0
44 1 Hive_Sense01.eth2
68 1 Hive-NSX-Manager.eth0
22 1 MK_WIN_01.eth0
88 1 RHUI-Client01.eth0
86 1 CDS01.eth0
89 1 RHUI-RHEL8-01.eth0
84 1 Repostore.eth0
95 1 lab-svr-01.eth0
96 1 lab-svr-02.eth0

C) Add VLAN ID to port group

Command syntax:

esxcfg-vswitch <vSwitch Name> –v <VLAN ID> -p <Port Group Name>

[root@datahivehost1:~] esxcfg-vswitch vSwitch_NFS -v 123 -p testpg

verify VLAN ID of port group

[root@datahivehost1:~] esxcfg-vswitch -l
Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch0 5376 14 128 1500 vmnic0

PortGroup Name VLAN ID Used Ports Uplinks
VM_Management 888 6 vmnic0
VMVLAN1 1 3 vmnic0
vmotion 188 1 vmnic0
ManagementNetwork 888 1 vmnic0

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch_NFS 5376 4 1024 1500 vmnic3

PortGroup Name VLAN ID Used Ports Uplinks
testpg 123 0 vmnic3
DATA_LAN 0 0 vmnic3
NFS 567 1 vmnic3

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch_VM_Network 5376 1 1024 1500

PortGroup Name VLAN ID Used Ports Uplinks

DVS Name Num Ports Used Ports Configured Ports MTU Uplinks
DATAHIVEDSwitch 5376 17 512 9000 vmnic1,vmnic2

DVPort ID In Use Client
34 1 vmnic1
35 1 vmnic2
18 1 MK_WIN16-01.eth0
45 1 Hive_Sense02.eth2
21 1 MK_Desktop02.eth0
44 1 Hive_Sense01.eth2
68 1 Hive-NSX-Manager.eth0
22 1 MK_WIN_01.eth0
88 1 RHUI-Client01.eth0
86 1 CDS01.eth0
89 1 RHUI-RHEL8-01.eth0
84 1 Repostore.eth0
95 1 lab-svr-01.eth0
96 1 lab-svr-02.eth0

D) Delete Port Group on existing vSwitch

Command syntax:

esxcfg-vswitch –D <Port Group Name> <vSwitch Name>

[root@datahivehost1:~] esxcfg-vswitch -D testpg vSwitch_NFS

verify port group info

[root@datahivehost1:~] esxcfg-vswitch -l
Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch0 5376 14 128 1500 vmnic0

PortGroup Name VLAN ID Used Ports Uplinks
VM_Management 888 6 vmnic0
VMVLAN1 1 3 vmnic0
vmotion 188 1 vmnic0
ManagementNetwork 888 1 vmnic0

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch_NFS 5376 4 1024 1500 vmnic3

PortGroup Name VLAN ID Used Ports Uplinks
DATA_LAN 0 0 vmnic3
NFS 567 1 vmnic3

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch_VM_Network 5376 1 1024 1500

PortGroup Name VLAN ID Used Ports Uplinks

DVS Name Num Ports Used Ports Configured Ports MTU Uplinks
DATAHIVEDSwitch 5376 17 512 9000 vmnic1,vmnic2

DVPort ID In Use Client
34 1 vmnic1
35 1 vmnic2
18 1 MK_WIN16-01.eth0
45 1 Hive_Sense02.eth2
21 1 MK_Desktop02.eth0
44 1 Hive_Sense01.eth2
68 1 Hive-NSX-Manager.eth0
22 1 MK_WIN_01.eth0
88 1 RHUI-Client01.eth0
86 1 CDS01.eth0
89 1 RHUI-RHEL8-01.eth0
84 1 Repostore.eth0
95 1 lab-svr-01.eth0
96 1 lab-svr-02.eth0

E) Create new vSwitch

Command syntax:

esxcfg-vswitch –a <vSwitch Name>

[root@datahivehost1:~] esxcfg-vswitch -a testVSS
[root@datahivehost1:~] esxcfg-vswitch -l
Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch0 5376 14 128 1500 vmnic0

PortGroup Name VLAN ID Used Ports Uplinks
VM_Management 888 6 vmnic0
VMVLAN1 1 3 vmnic0
vmotion 188 1 vmnic0
ManagementNetwork 888 1 vmnic0

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch_NFS 5376 4 1024 1500 vmnic3

PortGroup Name VLAN ID Used Ports Uplinks
DATA_LAN 0 0 vmnic3
NFS 567 1 vmnic3

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch_VM_Network 5376 1 1024 1500

PortGroup Name VLAN ID Used Ports Uplinks

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
testVSS 5376 1 128 1500

PortGroup Name VLAN ID Used Ports Uplinks

DVS Name Num Ports Used Ports Configured Ports MTU Uplinks
DATAHIVEDSwitch 5376 17 512 9000 vmnic1,vmnic2

DVPort ID In Use Client
34 1 vmnic1
35 1 vmnic2
18 1 MK_WIN16-01.eth0
45 1 Hive_Sense02.eth2
21 1 MK_Desktop02.eth0
44 1 Hive_Sense01.eth2
68 1 Hive-NSX-Manager.eth0
22 1 MK_WIN_01.eth0
88 1 RHUI-Client01.eth0
86 1 CDS01.eth0
89 1 RHUI-RHEL8-01.eth0
84 1 Repostore.eth0
95 1 lab-svr-01.eth0
96 1 lab-svr-02.eth0

F) Assign uplink to vSwitch

Command Syntax:

esxcfg-vswitch –L <primary NIC> <vSwitch Name>

[root@datahivehost1:~] esxcfg-vswitch -L vmnic4 testVSS
[root@datahivehost1:~] esxcfg-vswitch -l
Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch0 5376 14 128 1500 vmnic0

PortGroup Name VLAN ID Used Ports Uplinks
VM_Management 888 6 vmnic0
VMVLAN1 1 3 vmnic0
vmotion 188 1 vmnic0
ManagementNetwork 888 1 vmnic0

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch_NFS 5376 4 1024 1500 vmnic3

PortGroup Name VLAN ID Used Ports Uplinks
DATA_LAN 0 0 vmnic3
NFS 567 1 vmnic3

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch_VM_Network 5376 1 1024 1500

PortGroup Name VLAN ID Used Ports Uplinks

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
testVSS 5376 3 128 1500 vmnic4

PortGroup Name VLAN ID Used Ports Uplinks

DVS Name Num Ports Used Ports Configured Ports MTU Uplinks
DATAHIVEDSwitch 5376 17 512 9000 vmnic1,vmnic2

DVPort ID In Use Client
34 1 vmnic1
35 1 vmnic2
18 1 MK_WIN16-01.eth0
45 1 Hive_Sense02.eth2
21 1 MK_Desktop02.eth0
44 1 Hive_Sense01.eth2
68 1 Hive-NSX-Manager.eth0
22 1 MK_WIN_01.eth0
88 1 RHUI-Client01.eth0
86 1 CDS01.eth0
89 1 RHUI-RHEL8-01.eth0
84 1 Repostore.eth0
95 1 lab-svr-01.eth0
96 1 lab-svr-02.eth0

G) Delete vSwitch

Command Syntax:

esxcfg -vswitch -d <vSwitch Name>

[root@datahivehost1:~] esxcfg-vswitch -d testVSS
[root@datahivehost1:~] esxcfg-vswitch -l
Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch0 5376 14 128 1500 vmnic0

PortGroup Name VLAN ID Used Ports Uplinks
VM_Management 888 6 vmnic0
VMVLAN1 1 3 vmnic0
vmotion 188 1 vmnic0
ManagementNetwork 888 1 vmnic0

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch_NFS 5376 4 1024 1500 vmnic3

PortGroup Name VLAN ID Used Ports Uplinks
DATA_LAN 0 0 vmnic3
NFS 567 1 vmnic3

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch_VM_Network 5376 1 1024 1500

PortGroup Name VLAN ID Used Ports Uplinks

DVS Name Num Ports Used Ports Configured Ports MTU Uplinks
DATAHIVEDSwitch 5376 17 512 9000 vmnic1,vmnic2

DVPort ID In Use Client
34 1 vmnic1
35 1 vmnic2
18 1 MK_WIN16-01.eth0
45 1 Hive_Sense02.eth2
21 1 MK_Desktop02.eth0
44 1 Hive_Sense01.eth2
68 1 Hive-NSX-Manager.eth0
22 1 MK_WIN_01.eth0
88 1 RHUI-Client01.eth0
86 1 CDS01.eth0
89 1 RHUI-RHEL8-01.eth0
84 1 Repostore.eth0
95 1 lab-svr-01.eth0
96 1 lab-svr-02.eth0

Basic Fortigate Health Check – CLI Command

I. Check System Status

get system status

Use this command to display system status information including:

  • Firmware version, build number and date
  • License and registration status
  • Serial number
  • WAF database version
  • IP Reputation database version
  • Log disk availability
  • Hostname
  • Current HA mode
  • Uptime
  • System time

IGS-FW-FG100D # get system status
Version: FortiGate-100D v6.0.0,build0076,180329 (GA)
Virus-DB: 76.00258(2020-03-26 22:19)
Extended DB: 76.00258(2020-03-26 22:19)
IPS-DB: 15.00770(2020-02-04 02:44)
IPS-ETDB: 15.00770(2020-02-04 02:44)
APP-DB: 15.00770(2020-02-04 02:44)
INDUSTRIAL-DB: 13.00407(2018-07-06 01:54)
Serial-Number: FG100D3G14815591
IPS Malicious URL Database: 2.00594(2020-03-26 04:32)
Botnet DB: 4.00628(2020-01-27 18:36)
BIOS version: 05000004
System Part-Number: P11510-04
Log hard disk: Not available
Hostname: IGS-FW-FG100D
Operation Mode: NAT
Current virtual domain: root
Max number of virtual domains: 10
Virtual domains status: 1 in NAT mode, 0 in TP mode
Virtual domain configuration: disable
FIPS-CC mode: disable
Current HA mode: standalone
Branch point: 0076
Release Version Information: GA
FortiOS x86-64: Yes
System time: Wed May 13 14:22:59 2020

II. Display Fortigate Hardware info

get hardware status

  • Display forigate hardware info – FortiASIC version, CPU type, amount of memory, flash drive size, hard disk size (if present), USB flash size (if present), network card chipset, and WiFi chipset (FortiWifi models).
Continue reading