VLANs are isolated broadcast domains that run over a single physical network. They allow you to segment a local network and also to “stretch” a LAN over multiple physical locations. Most enterprises implement this on their network switching environment, but in some cases, the tagged VLANs reach your server.
In order to configure a VLAN, we need an established network connection on the local network interface.
For the sake of ease, our physical network interface is called
eth0. The VLAN’s ID is 1, and the IPv4 address is
10.0.0.2, with a subnet mask of
255.0.0.0 and a default gateway of
Creating the VLAN connection with nmcli
nmcli, we need to first create the connection and then activate it. Perform the following steps:
- Create a VLAN interface using the following command:
~]# nmcli connection add type vlan dev eth0 id 1 ip4 10.0.0.2/8 gw4 10.0.0.1 Connection 'vlan' (4473572d-26c0-49b8-a1a4-c20b485dad0d) successfully added. ~]#
- Now, via this command, activate the connection:
~]# nmcli connection up vlan Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7) ~]#
- Check your network connection, as follows:
~]# nmcli connection show ~]# nmcli device status ~]# nmcli device show eth0.1
Here is an example output of the preceding commands:
Creating the VLAN connection with nmtui
nmtui tool is a text user interface to
NetworkManager and is launched by executing the following in a terminal:
This will bring up the following text-based interface:
Navigation is done using the Tab and arrow keys, and the selection is done by pressing the Enter key. Now, you need to do the following:
- Go to Edit a connection and select <OK>. The following screen will appear:
2.Next, select <Add> and the VLAN option. Confirm by Selecting <Create>:
3.Enter the requested information in the following form and commit by selecting <OK>:
Your new VLAN interface will now be listed in the connections list:
Creating the VLAN connection with kickstart
Let’s explore what you need to add to your
kickstart script in order to achieve the same result as in the preceding section:
- Look for the configuration parameters within your
kickstartfile with the following command:
... network --device=eth0 ...
- Replace it with the following configuration parameters:
network --device=eth0 --vlanid=1 --bootproto=static --ip=10.0.0.2 --netmask=255.0.0.0 --gateway=10.0.0.1
The command line to create a VLAN with
nmcli is pretty basic as it uses default values for every piece of information that is missing. To make sure that everything is created to your wishes, it is wise to also use
These will respectively name your connection and the device you’re creating.
Take a look at the following command:
~]# nmcli connection add type vlan con-name vlan1 ifname eth0.1 dev eth0 id 1 ip4 10.0.0.2/8 gw4 10.0.0.1
This will create the
vlan.1 connection with
eth0 as the parent and
eth0.1 as the target device.
nmtui, you can name your VLAN connection in
kickstart; you only need to specify the
--interfacename option. If you cannot find any previous network configuration in your
kickstart file, just add the code to your
nmcli tool lacks a man page, but execute the following command for more options to create VLAN connections:
~]# nmcli con add help
kickstart information on networks, check the following URL: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Installation_Guide/sect-kickstart-syntax.html.