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 10.0.0.1
.
With nmcli
, we need to first create the connection and then activate it. Perform the following steps:
~]# 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. ~]#
~]# nmcli connection up vlan Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7) ~]#
~]# nmcli connection show ~]# nmcli device status ~]# nmcli device show eth0.1
The nmtui
tool is a text user interface to NetworkManager
and is launched by executing the following in a terminal:
~]# nmtui
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:
Your new VLAN interface will now be listed in the connections list:
Let's explore what you need to add to your kickstart
script in order to achieve the same result as in the preceding section:
kickstart
file with the following command:... network --device=eth0 ...
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 con-name
and ifname
. 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.
As with nmcli
and 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 kickstart
file.
The nmcli
tool lacks a man page, but execute the following command for for more options to create VLAN connections:
~]# nmcli con add help
For more 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.