VLAN: Set up 802.1q VLAN trunk in CentOS & RedHat

 

This article explains how to set up a VLAN trunk configuration in CentOS and RedHat.

Contents

  • VLAN ?
  • Set up a VLAN configuration

1- VLAN:

VLAN is Virtual Local Area Network. That’s mean several LANs can co-exist on a single physical network card. Since Linux 2.4, Linux support’s the 802.1q driver and if you are more than 2 servers (more than 2 NIC card) you should have a switch that support the VLAN network.

vlan

VLAN Concepts

2- Set up a VLAN configuration:

I have two stations with one network card each one (eth0):

1-      Configure the Ethernet interface eth0.

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet

2-      Create a VLAN with ID 10

# Vi /etc/sysconfig/network-scripts/ifcfg-eth0.10
DEVICE=eth0.10
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.10.X
NETMASK=255.255.255.0
USERCTL=no
VLAN=yes

3-      Create a VLAN with ID 20

# Vi /etc/sysconfig/network-scripts/ifcfg-eth0.20
DEVICE=eth0.20
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.20.X
NETMASK=255.255.255.0
USERCTL=no
VLAN=yes

4- Restart the networking  service:

# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:                                [  OK  ]
Bringing up interface eth0.10:  Added VLAN with VID == 10 to IF -:eth0:-
                                                           [  OK  ]
Bringing up interface eth0.20:  Added VLAN with VID == 20 to IF -:eth0:-
                                                           [  OK  ]

 

Note: On the other station (station2), do the same configurations for the eth0 network interface: ifcfg-eth0, ifcfg-eth0.10 and ifcfg-eth0 just change the IP address (.X to .Y)

5- Module is loaded:

The driver name 8021q on Linux which manage the VLAN

# lsmod | grep 802
8021q                 19811      0

 

 3- Conclusion:

With the VLAN, you can create many LAN with one network card (logically separated).

 

 

Bookmark the permalink.
Loading Facebook Comments ...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.