GIT – Section 1. How do I configure my Red Hat system to use 802.1q Virtual Local Area Network (VLAN) tagging for all network communication?
When connected to a properly configured network device, your Red Hat system can communicate over a network using 802.1q Virtual Local Area Network (VLAN) tagged frames. The necessary kernel module, 8021q, is already available in the 2.4+ kernel.
To use tagged traffic exclusively, create additional ifcfg-ethX.Y files, where X is the interface on which you will use the VLAN and Y is the VLAN ID. For example, on a system with one network card (eth0) that needs to talk to two different VLANs with VLAN IDs 10 and 11, you’ll need these files:
/etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.10 /etc/sysconfig/network-scripts/ifcfg-eth0.11
These files will configure your system to have two virtual Ethernet interfaces called eth0.10 and eth0.11 that use tagged frames for communication to VLANs 10 and 11. To create the configuration files for the virtual tagged interfaces, copy the contents of your original ifcfg-eth0 file to ifcfg-eth0.10 and ifcfg-eth0.11. Then comment out or remove everything in your ifcfg-eth0 file except for
Next, edit the DEVICE= line in the ifcfg-eth0.10 and ifcfg-eth0.11 files so that they read eth0.10 and eth0.11 respectively. Add the lineVLAN=yes to both files. Finish configuring these virtual adapters with the correct IP address and subnet mask for each VLAN, or with aBOOTPROTO=dhcp line if addresses are given out via DHCP. Don’t forget to include a default gateway in /etc/sysconfig/network. It’s important to remember that you can only have one default gateway.
Issue the command:
# service network restart
to complete the process. The VLAN=yes entries cause the network startup scripts to automatically run the vconfig command to add the necessary VLAN entries in /proc/net/vlan for each VLAN tag.
Here are the completed files for a network set up to only transmit tagged frames and with both virtual adapters set to use DHCP:
Section 2. /etc/sysconfig/network-scripts/ifcfg-eth0
Section 3. /etc/sysconfig/network-scripts/ifcfg-eth0.10
1) Without IP Address
DEVICE=eth0.10 HWADDR=XX:XX:XX:XX:XX:XX ONBOOT=yes TYPE=Ethernet VLAN=yes
2) With IP Address on VLAN Interface
DEVICE=eth0.10 BOOTPROTO=static HWADDR=XX:XX:XX:XX:XX:XX IPADDR=10.10.10.1 NETMASK=255.255.255.0 NETWORK=10.10.10.0 ONBOOT=yes TYPE=Ethernet VLAN=yes
Section 4. /etc/sysconfig/network-scripts/ifcfg-eth0.11
1) With DHCP Client
DEVICE=eth0.11 BOOTPROTO=dhcp HWADDR=XX:XX:XX:XX:XX:XX ONBOOT=yes TYPE=Ethernet VLAN=yes
Section 5. Remove VLAN Interface
If you accidentally created a virtual adapter with the wrong VLAN ID, you may need to use the vconfig command to remove it from the /proc filesystem. Just restarting the network service won’t do that for you. For example, if you accidentally created a virtual adapter called eth0.12, the following command will remove it from /proc/net/vlan:
# vconfig rem eth0.12