There are some scenarios where we want to assign multiple IPs from different VLAN on the same Ethernet card (nic) on Linux servers (CentOS / RHEL). This can be done by enabling VLAN tagged interface.
Let’s assume we have a Linux Server, there we have one Ethernet card (
So attach VLANs 4 tag to NIC
em1 using the
ip link add link em1 name vlan4 type vlan id 4
To view the VLAN, issue the following command:
ip -d link show vlan4
Bring up the interface using below ip command:
ip link set dev vlan4 up
Now we can assign the IP address to tagged interface from their respective VLANs using beneath ip command,
ip addr add 172.16.3.188/24 dev vlan4
To delete created VLAN interface use next command
ip link delete dev vlan4@em1
It will work to the next reboot.
For saving the configuration edit the network settings stored in directory
- ip command cheat sheet - For Red Hat Enterprise Linux.
- Configure 802.1q vlan tagging using the command line - Manual from RHEL authors.
- How to Configure VLAN tagged NIC (Ethernet Card) on Linux Servers- Another instruction to configure VLAN on Linux.