Do More With Less: 802.1Q VLANs with Voyage Linux - Page 2
Permanent VLAN Client Configurations
Naturally, every danged Linux distribution has its own pet method for configuring network interfaces. A pox on all of them. Fortunately, the majority are either Debian-derivatives or Red Hat offspring, so we can cover a lot of distributions with examples from those two. Your favorite graphical network configurator may not let you do VLANs, so here is how we do it the old-fashioned way.
Debian is easy- there is a single configuration file, /etc/network/interfaces. I know, the hot new trend is to take even the simplest configurations and split them among a half-dozen widely-scattered and undocumented configuration files, to maximize unpredictable behavior and user confusion, but fortunately Debian has resisted this trend. So far. This is what a single VLAN interface looks like.
auto eth0 iface eth0 static 0.0.0.0 up vconfig add eth0 5 auto eth0.5 iface eth0.5 inet dhcp
auto eth0 iface eth0 static 0.0.0.0 up vconfig add eth0 5 auto eth0.5 iface eth0.5 inet static address 192.168.5.25 netmask 255.255.255.0 network 192.168.5.0 broadcast 192.168.5.255 gateway 192.168.5.1
You can add as many more as you want on the same interface, and you can use a non-zero address on the base interface if you want.
Red Hat put the B in Byzantine network interface configuration, and Fedora, CentOS, PCLinuxOS, and hordes of others follow suit. This shows a static address. You'll configure two files:
#/etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 ONBOOT=no TYPE=Ethernet #/etc/sysconfig/network-scripts/ifcfg-eth0.5 DEVICE=eth0.5 HWADDR=00:BB:6A:FE:77:EE IPADDR=192.168.5.25 NETMASK=255.255.255.0 VLAN=yes ONBOOT=yes BOOTPROTO=none
This shows how to configure DHCP:
#/etc/sysconfig/network-scripts/ifcfg-eth0.5 DEVICE=eth0.5 BOOTPROTO=dhcp HWADDR=00:BB:6A:FE:77:EE ONBOOT=yes TYPE=Ethernet VLAN=yes
And don't forget /etc/sysconfig/network, which is where you set the default gateway and other global network information:
NETWORKING=yes HOSTNAME=vlanqueen GATEWAY=192.168.5.1 DOMAINNAME=foobeer.net GATEWAYDEV=eth0.5
More Switches! More!
OK then. Now for the final burning basic 802.1Q question: What about adding more switches? Easy. Just plug the suckers together, and remember to uplink them using tagged ports. You can create VLANs that span switches and still use a single router, so check your switch documentation for details. For troubleshooting use ping, mtr, route, and tcpdump or Wireshark.