Tuesday, January 29, 2008

Quickly - configuring VLANs on Linux

This post is similar to the one about configuring VLANs on RHEL but is applicable on any Linux distribution. VLANs support has been included into the Linux kernel since version 2.4.14. Earlier versions requires to be patched properly. More about it and patches is placed here. Again, configuration steps which requires to be done as root:
  1. we have already configured eth0 interface which is accessible from the network and we want to add VLAN support to it, e.g. to accept packets tagged with VLAN ID 123 (avoid using VLAN ID 1, it is often used as administration VLAN)
  2. we need to have support at the kernel level, try to load the proper module
    • modprobe 8021q
  3. you don't need to know how to modify configuration file's of interface eth0 because we are going to use the vconfig command to do it
  4. to turn on VLAN ID 123 on the interface eth0, use the command:
    • vconfig add eth0 123
  5. check that the previous command was applied successfully, you can use ifconfig command of course:
    • ifconfig eth0.123
  6. finally, configure the remaining settings you want to set for the interface eth0, do it with ifconfig again
  7. to make the changes persistent place the commands to some rc script or create your own init script and enable it during system boot
  8. to check the status, kernel has exported some status information here:
    • cat /proc/net/vlan/eth0.123
  9. if you want to remove the interface, try these two:
    • ifconfig eth0.123 down
    • vconfig rem eth0.123

No comments: