Rate this page

Configure an Ethernet interface as a VLAN trunk (Red Hat)

Specific to

Red Hat-based distributions

Tested on

CentOS (5.5)


To configure an Ethernet interface as an IEEE 802.1Q VLAN trunk on a Red Hat-based distribution.


See Configure an Ethernet interface as a VLAN trunk.


Suppose that a host requires access to two VLANs, both carried by a trunk connected to physical interface eth0. The assigned IP addresses for the host are on VLAN 2 and on VLAN 3.


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:

The interface naming convention used and recommended here 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.2:


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


Bring up the interfaces in the normal way using ifup:

ifup eth0.2
ifup eth0.3


After invoking ifup you should be able to inspect the new VLAN interfaces using the ifconfig command:

ifconfig eth0.2

which should give output of the form:

eth0.2    Link encap:Ethernet  HWaddr 00:00:00:00:00:00
          inet addr:  Bcast:  Mask:
          UP BROADCAST MULTICAST  MTU:1500 Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)


Invoking ifup has no effect

If ifup has no apparent effect (no output, no new interface reported by ifconfig) this could indicate that the specified physical Ethernet device does not exist.

Device does not appear to be present

An error of the form:

Device eth0.2 does not seem to be present, delaying initialization.

could indicate that:

No VLAN support in kernel

An error of the form:

No 802.1Q VLAN support available in kernel for device eth0.2

indicates that the kernel module needed to provide VLAN support has not been loaded. It should load automatically when you invoke ifup. Determine whether this has happened using the lsmod command, which lists the kernel modules that are currently loaded. You are looking for one called 8021q (with no dot between 802 and 1q):

lsmod | grep 8021q

If the module is not listed then the most likely explanation is that it could not be found. Confirm this by attempting to manually load it using the command modprobe:

modprobe 8021q

This should give an error of the form:

FATAL: Could not open '/lib/modules/2.6.18-194.el5/kernel/net/8021q/8021q.ko': No such file or directory

The most likely explanation for a failure of this type is that you are running a different kernel from the one that was originally installed but have not provided a matching set of kernel modules. If this is the case then there will be no directory in /lib/modules with a name that matches the running kernel version.

Alternative possibilities are that the file in question has been deleted somehow, or you are running a custom kernel that does not include 802.1Q support.


You may encounter interface scripts in which the physical interface name is specified explicitly by means of the PHYSDEV setting. This is only needed when using a naming convention that does not incorporate the physical interface name, for example:


Disadvantages of this approach are that there is more to go wrong, and it does not allow for multiple interfaces with the same VLAN number.

See also

Tags: 802.1q | ethernet | vlan