[label=\file{/etc/network/interfaces}]
auto eth0.0
iface eth0.0 inet static
switch-ports 1 2 5*
address 192.168.1.1
netmask 255.255.255.0
auto eth0.1
iface eth0.1 inet static
switch-ports 3 4 5
address 192.168.2.1
netmask 255.255.255.0
auto eth0.2
iface eth0.2 inet static
switch-ports 0 5
address 172.16.1.42
netmask 255.255.255.0
gateway 172.16.1.1
This configures three VLAN interfaces eth0.0 on ports 1 and 2, eth0.1 on port 3 and 4 and eth0.2 on port 0.
If you need to do some advanced settings, because you have for example a powerful switch with a VLAN trunking port connected to one of your switch ports, the configuration would look like this:
[label=\file{/etc/network/interfaces}]
auto eth0.1
iface eth0.1 inet static
switch-ports 2 3 4 5*
address 192.168.1.1
netmask 255.255.255.0
auto eth0.2
iface eth0.2 inet static
switch-ports 1t 5
address 10.2.0.1
netmask 255.255.255.0
broadcast +
auto eth0.3
iface eth0.3 inet static
switch-ports 1t 5
address 10.3.0.1
netmask 255.255.255.0
broadcast +
auto eth0.4
iface eth0.4 inet static
switch-ports 1t 5
address 10.4.0.1
netmask 255.255.255.0
broadcast +
This configures four VLAN interfaces, eth0.1 on physical ports 2, 3 and 4. The interfaces eth0.2, eth0.3 and eth0.4 are three different networks with VLAN ID 2–4. The physical port 1 needs to be connected to a VLAN trunking port on a switch with knows the same VLAN IDs.
Explanation: