Configuring VLAN's

There are a couple of ways for configuring VLAN's.  The most generic method, would be the use of vconfig.  If you've not got this installed, you'll need to install this package.  In addition to this, your kernel will require support for 802.1q which is under the Networking section.

After you've met those requirements, VLAN's can be configured as follows:

vconfig add ethx xx

where ethx is your network card and xx is the VLAN number you wish to assign.  So, for example:

vconfig add eth0 10

would assign an eth0 device for VLAN 10.  You can do this multiple times, so:

vconfig add eth0 20
vconfig add eth0 30
vconfig add eth0 40

would then mean you've got three more VLAN's on your eth0 device.  Issuing an ifconfig -a, will display all devices, and you'll normally see the name of the interface followed by the VLAN.  They are named as:

eth0.10
eth0.20
eth0.30
eth0.40

and so on.  Configuring the interface can then be done in the usual manner:

ifconfig eth0.10 192.168.1.10/24
ifconfig eth0.20 192.168.2.10/24
ifconfig eth0.30 192.168.3.10/24
ifconfig eth0.40 192.168.4.10/24

Another method, in particular - RPM-based distros, it can be done another way.  Copy the /etc/sysconfig/network-scripts/ifcfg-eth0 file to /etc/sysconfig/network-scripts/ifcfg-eth0.10 and so on.  Then edit this file, and change the reference to eth0 to eth0.10 so that the device will be identified correctly.  Then, add to the file the correct IP information and the following extra option:

VLAN=yes

all you then need to worry about is ensuring that 802.1q support is compiled into the kernel.  vconfig might also be handy, in case you want to use it at some point - so install if you like.  Restarting your networking service or rebooting will enable the interfaces for you.