Home > Featured, Linux How to, Pro Linux > Linux VLAN configuration

Linux VLAN configuration

baby tux 01 150x150 Linux VLAN configuration Linux VLAN Configuration – The basics

VLAN is the short acronym for “Virtual LAN” which basically translates into creating multiple, separated LAN segments on the same physical switch without the need to use multiple network switches/cables to break up the network into smaller and more manageable entities. VLAN are created for a variety of reasons among which :

  • Network performance
  • Network security
  • Manageability

A complete and detailed description of VLAN is out of the scope of this post but if you are interested you can find a pretty explanatory article here.

Linux VLAN Configuration – HowTo

In today’s network using VLAN is pretty common and luckily enough usually you don’t have to worry about configuring Linux VLAN to tag traffic directly at the “source” but also if you need to configure Linux to support VLAN tagging take heart as the process is pretty easy and straightforward.

First of all you should gather information about your network, specifically you need to know the VLAN tag that Linux should add to outgoing traffic, for the sake of this post we will use interface eth0 and a VLAN with ID 550 so with this out of the way let’s start the Linux VLAN configuration.

Linux VLAN Configuration – Define VLAN interfaces

The first step into configuring Linux VLAN is editing the interface configuration file, in our example eth0, to resemble what depicted below :

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

DEVICE="eth0"
HWADDR="00:19:B9:2F:6E:71"
NM_CONTROLLED="no"
ONBOOT="yes" 

Once you have modified the eth0 configuration you need to setup the VLAN configuration file so that the Linux system will be able to send out tagged traffic so create a file named after the VLAN ID like this :

 vi  /etc/sysconfig/network-scripts/ifcfg-vlan450

VLAN="yes"
VLAN_NAME_TYPE="VLAN_PLUS_VID_NO_PAD"
DEVICE="vlan450"
PHYSDEV="eth0"
BOOTPROTO="static"
ONBOOT="yes"
TYPE="Ethernet"
IPADDR="10.10.10.100"
NETMASK="255.255.255.0" 

Once you are done editing the file all you have to do is to restart network services to make the changes effective with a command like :

 service network restart 

Linux VLAN Configuration – Alternative method

If your are not comfortable editing configuration file or simply feel like trying something different there is an alternate way to configure Linux VLAN interfaces, in this case make you have installed the package vconfig which does not come with the default installation :

 yum install vconfig 

Once you have installed the package you can use the command vconfig to configure Linux VLAN let’s see how it works.

  vconfig add eth0 450 

The above command will add the necessary configuration so that interface eth0 can send traffic tagged for VLAN 450, if you need to configure Linux VLAN for multiple networks you can use a command like the following :

 vconfig add eth0 10

vconfig add eth0 450 

Now that you have configured your system to support VLAN you can assign an IP address to the interface created with the ifconfig command :

 ifconfig eth0.450 10.10.10.100 netmask 255.255.255.0 broadcast 10.10.10.255 up 

You can view the information the configured Linux VLAN device with the following command :

 cat /proc/net/vlan/eth0.450 

If you need to remove the VLAN configuration you can do so with vconfig command like in :

 vconfig rem eth0.450 

Well that’s pretty much everything about the Linux VLAN configuration, I hope you did find the article useful and will take a second to retweet it or leave me a comment.

Cheers Lethe.

VN:F [1.9.20_1166]
Rating: 5.0/5 (3 votes cast)
Linux VLAN configuration, 5.0 out of 5 based on 3 ratings

Incoming search terms:

  • Rajeewa

    good Article very simple

    • http://blog.tuxforge.com Lethe

      Glad you appreciated it.

      Thanks for taking the time to leave a comment!