How to‎ > ‎

Configure VLANs on CentOS

Sometimes is rewuired on CentOS servers to make use of VLANs. currently, almost any managed ethernet switch is capable of using tagged VLANs encapsulated in the industrial 'de facto' format: 802.1q.

To make use of 802.1q VLAN on CentOS there is no additional package needed, all the required tools are available even in the minimal installation.

First required step is to enable the physical interface, preferably without any ip address. Since the system-config-network-tui tool is not able at this time to configure an interface without enabling DHCP, it is preferable to edit the configuration file manually.

In this example, I will use the interface eth0, which will transport packets for two vlans: vlan 10 and vlan 11.

Three configuration files must be edited:

/etc/sysconfig/network-scripts/ifcfg-eth0

# Intel Corporation 82546EB Gigabit Ethernet Controller (Copper)
DEVICE=eth0
HWADDR=00:04:xx:xx:xx:xx
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=none
TYPE=Ethernet
IPV6INIT=no
IPV6_AUTOCONF=no


The most important settings for eth0 are:
ONBOOT=yes : the interface will be brought up automatically
BOOTPROTO=none : the interface will have the ip address set manually, and no address is specified. This means that the interface will be brought up without an IPv4 address
IPV6INIT=no : the IPv6 stack will not be bounded to this interface
IPV6AUTOCONF=no : IPv6 autoconfiguration is disabled for this interface

/etc/sysconfig/network-scripts/ifcfg-eth0.10

# Intel Corporation 82546EB Gigabit Ethernet Controller (Copper)
DEVICE=eth0.10
HWADDR=00:04:xx.xx.xx.xx
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=none
TYPE=Ethernet
VLAN=yes
IPADDR=86.X.X.X
NETMASK=255.255.X.X

/etc/sysconfig/network-scripts/ifcfg-eth0.11

# Intel Corporation 82546EB Gigabit Ethernet Controller (Copper)
DEVICE=eth0.11
HWADDR=00:04:xx.xx.xx.xx
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=none
TYPE=Ethernet
VLAN=yes
IPADDR=86.X.X.X
NETMASK=255.255.X.X

Now it's time to start the interfaces. This can be done manually, using /sbin/ifup:
/sbin/ifup eth0
/sbin/ifup eth0.10
/sbin/ifup eth0.11

Or by using /sbin/service:
/sbin/service network restart

Comments