Creating a VLAN interface

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.

Getting ready

In order to configure a VLAN, we need an established network connection on the local network interface.

How to do it…

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.

Creating the VLAN connection with nmcli

With nmcli, we need to first create the connection and then activate it. Perform the following steps:

  1. 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.
    ~]#
    
  2. Now, via this command, activate the connection:
    ~]# nmcli connection up vlan
    Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
    ~]#
    
  3. 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 nmcli

Creating the VLAN connection with nmtui

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:

Creating the VLAN connection with nmtui

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:

  1. Go to Edit a connection and select <OK>. The following screen will appear:
    Creating the VLAN connection with nmtui
  2. Next, select <Add> and the VLAN option. Confirm by Selecting <Create>:
    Creating the VLAN connection with nmtui
  3. Enter the requested information in the following form and commit by selecting <OK>:
    Creating the VLAN connection with nmtui

Your new VLAN interface will now be listed in the connections list:

Creating the VLAN connection with nmtui

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:

  1. Look for the configuration parameters within your kickstart file with the following command:
    ...
    network --device=eth0
    ...
  2. 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

There's more…

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.

See also

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset