Configure VLAN trunk on CentOS/RedHat

Reading Time: < 1 minute

If you need to create a tagged VLAN on you CentOS/RedHat distribution follow this simple guide.
I’ll try to explain how to reach this goal with an example. after that
Suppose that a host should reach two differents VLANs both carried by a trunk connected to physical interface and that the first eth has ip 192.168.100.1/24 (VLAN 100) and the second 192.168.200.1/24 (VLAN 200).

Fist of all you have to add an interface script for each VLAN to /etc/sysconfig/network-scripts/.

This follows the same format as one for a normal Ethernet interface except that:

  • it must contain the setting VLAN=yes,
  • the interface name must follow one of the naming conventions supported by vconfig (see below), and
  • the MAC address (HWADDR) need not be specified.

The interface naming convention used is of the form ethx.y, where ethx is the physical interface name and y is the VLAN number.
For the scenario described above two interface scripts are needed, one with the pathname/etc/sysconfig/network-scripts/ifcfg-eth0.100:

VLAN=yes
DEVICE=eth0.100
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.100.1
NETMASK=255.255.255.0

and one with the pathname /etc/sysconfig/network-scripts/ifcfg-eth0.200:

LAN=yes
DEVICE=eth0.200
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.200.1
NETMASK=255.255.255.0

After that just brig up both interfaces using command ifup or just restarting nwtwork service service network restart

Check Out koodzo.com!