Did you ever wonder how you can pass tagged VLANs to your CentOS system?
Hey, my name is "Tux" and this tutorial will show you how you can pass tagged VLAN traffic directly to your CentOS system so the CentOS system itself will tag/de-tag the network data packages instead of the according physical/virtual switch.
Basic informations
eth0
on which its top you want to set the VLAN to. This would mean that your new VLAN interface would be called eth0.100
, which would be based on the existing eth0
interface. In this case, the eth0
interface would be the parent network interface while the eth0.100
interface would be the child network interface.
First it is necessary to load the kernel module 8021q
into the kernel:
$ modprobe --first-time 8021q
To make sure whether the module has been loaded into the kernel, please execute the previous command again, which should return a similiar error message to:
modprobe: ERROR: could not insert '8021q': Module already in kernel
Optional
$ modinfo 8021q
Now execute…
$ ifconfig
…to find out the according parent network interface name you want to configure the VLAN interface on top of, which sould return something similiar to:
eth<myParentNetworkInterfaceNumber>
or
ens<myParentNetworkInterfaceNumber>
.
Now inside the directory…
/etc/sysconfig/network-scripts
…open the according file called
ifcfg-<myParentNetworkInterface>
:
$ vi ifcfg-<myParentNetworkInterface>
Comment out all content, except the following:
DEVICE=<myParentNetworkInterface>
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
Save the file and quit the editor.
Now create a new file…
$ vi ifcfg-<myParentNetworkInterface>.<myVLANID>
(e.g. ifcfg-ens160.100
)
…and add the following content:
DEVICE=<myParentNetworkInterface>.<myVLANID>
(e.g. DEVICE=ens160.100
)
BOOTPROTO=none
ONBOOT=yes
IPADDR=<myStaticAPAddress>
PREFIX=<mySubnetPrefix>
NETWORK=<myNetworkID>
GATEWAY=<myDefaultGatewayIPAddress>
VLAN=yes
Save the file and quit the editor.
Restart the network service:
$ systemctl restart network
Final note
Appreciate my work?
Buy me a coffee or PayPal
Source(s):
Red Hat: CONFIGURE 802.1Q VLAN TAGGING USING THE COMMAND LINE