Arrfab's Blog Linux tips and tricks …

17Sep/07Off

Multiple vlans on a single interface on CentOS (aka 802.1q tagging)

I had to setup a CentOS box that needed access to multiple VLANs configured in a bunch of Cisco switches ... Instead of having a different physical adapter for each vlan in linux, you can configure your physical interface with multiple logicals interfaces that will be 'tagged' (aka 802.1q vlan tagging). You need of course to configure your switch so that your eth0 will be in trunk mode ('switchport mode trunk' on cisco) and then configure logical interfaces on the linux side. A quick `grep -Ri vlan /usr/share/doc/initscripts-8.45.14.EL/` showed me that on CentOS you just need to create a /etc/sysconfig/network-scripts/ifcfg-eth0.30 (assuming that the vlan you need access to is vlan 30) and this file will have to look like this :

DEVICE=eth0.30
BOOTPROTO=STATIC
IPADDR=10.111.32.23
NETMASK=255.255.255.240
VLAN=yes
ONBOOT=yes

Of course you can fix parameters (dhcp, onboot, etc ...) like usual. A `ifup eth0.30` will bring this logical interface up (and will automatically modprobe the 8021q module) and you'll have access to machines sitting in this vlan 30 from your single eth0 physical inteface. Of course you can create multiple logical interfaces ...

Useful for example when you have a physical machine with a limited number of ethernet devices (like on IBM Blades ...)

Share and Enjoy:
  • Facebook
  • Twitter
  • Print
  • PDF
  • del.icio.us
  • Google Bookmarks
  • email
Filed under: CentOS Comments Off
Comments (0) Trackbacks (0)

Sorry, the comment form is closed at this time.

Trackbacks are disabled.