This is a quick howto on doing creating, destroying, managing VLANS on CentOS 7, RedHat , Fedora operating systems. A VLAN is an abstraction of a local area network (LAN) by allowing connectivity for a subnet. A network without VLAN would be able to pass only one subnet (network) but with VLAN's we can pass multiple networks through the same physical connection. In a typical production environment, there would be multiple VLANs , one for console management, for storage , for backup , for databases and different office departments.

This Howto will not explain what VLAN's are but will focus on creating, deleting and modifying VLAN interfaces.

Assume the following physical configuration and VLAN requirement:

  • vlan number 100 called FRONTEND which has network
  • vlan number 101 called BACKEND which has network

Find out current network interface setting and delete it:

Using nmcli con show

[[email protected] ~]# nmcli con show
NAME   UUID                                  TYPE      DEVICE 
ens33  a4fd84c3-d8dd-4851-be2d-2fb7f0e5b2a9  ethernet  ens33

Now delete it with :

nmcli con del ens33

Create the VLANS on the ens33 interface:

Add the Frontend VLAN as follows:

[email protected] ~]# nmcli con add type vlan con-name FRONTEND-VLAN id 100 dev ens33 ip4   
Connection 'FRONTEND-VLAN' (a47e1d16-ad56-4993-8143-9dafca53d05f) successfully added.

And add the Backend VLAN:

[[email protected] ~]# nmcli con add type vlan con-name BACKEND-VLAN id 101 dev ens33 ip4 
Connection 'BACKEND-VLAN' (2f46b7d8-8e83-48fa-bcb5-14477dfd3728) successfully added.

View the configuration

We can see the vlan's created with *nmcli show*

[[email protected] ~]# nmcli con show
NAME           UUID                                  TYPE      DEVICE    
BACKEND-VLAN   2f46b7d8-8e83-48fa-bcb5-14477dfd3728  vlan      ens33.101 
FRONTEND-VLAN  a47e1d16-ad56-4993-8143-9dafca53d05f  vlan      ens33.100

How to Delete VLAN interfaces

Delete by the NAME of the connection. To delete BACKEND-VLAN we do

nmcli connection delete BACKEND-VLAN