VLAN: Difference between revisions
(add table of contents) |
Captaindave (talk | contribs) (Got rid of configuration that would throw errors on boot; added per-VLAN MTU changes for purposes of illustration) |
||
Line 31: | Line 31: | ||
In those examples a static ip address was used but it works with dhcp as well. | In those examples a static ip address was used but it works with dhcp as well. | ||
== Example with vlans over bonding == | == Example with vlans over bonding with differing MTUs on the various VLANs == | ||
In this example we will [[Bonding|bond]] eth1 and eth2 interfaces and create vlan trunks with vid 8, 64 and 96. The gateway (ISP) is on eth0. | In this example we will [[Bonding|bond]] eth1 and eth2 interfaces and create vlan trunks with vid 8, 64 and 96. The gateway (ISP) is on eth0. | ||
<pre> | <pre> | ||
Line 39: | Line 39: | ||
auto bond0 | auto bond0 | ||
# use manual because the bond0 interface should not have any ip. | # use manual because the bond0 interface should not have any ip. | ||
# set your largest MTU here. | |||
iface bond0 inet manual | iface bond0 inet manual | ||
bond-slaves eth1 eth2 | bond-slaves eth1 eth2 | ||
post-up ip link set dev bond0 mtu 9000 | |||
# uses "default" MTU of 9000 | |||
auto bond0.8 | |||
iface bond0.8 inet static | iface bond0.8 inet static | ||
address 10.65.8.1 | address 10.65.8.1 | ||
netmask 255.255.255.0 | netmask 255.255.255.0 | ||
# uses standard MTU of 1500 | |||
auto bond0.64 | |||
iface bond0.64 inet static | iface bond0.64 inet static | ||
address 10.65.64.1 | address 10.65.64.1 | ||
netmask 255.255.255.0 | netmask 255.255.255.0 | ||
mtu 1500 | |||
auto bond0.96 | |||
iface bond0.96 inet static | iface bond0.96 inet static | ||
address 10.65.96.1 | address 10.65.96.1 |
Revision as of 16:34, 21 December 2015
This article shows how to configure a network interface as an IEEE 802.1q VLAN trunk.
Note: Alpine Linux v2.4 or later is required
Installation
First, install the vlan package. This will give you support for vlans in the /etc/network/interfaces file.
apk add vlan
Configuration
Edit the /etc/network/interfaces file:
auto eth0.8 iface eth0.8 inet static address 192.168.0.2 netmask 255.255.255.0 gateway 192.168.0.1
With the vlan package installed ifup will find the trailing .8 in eth0.8 and will create a vlan interface with vid 8 over eth0.
Alternative with vlan8 over eth0:
auto vlan8 iface vlan8 inet static address 192.168.0.2 netmask 255.255.255.0 gateway 192.168.0.1 vlan-raw-device eth0
In those examples a static ip address was used but it works with dhcp as well.
Example with vlans over bonding with differing MTUs on the various VLANs
In this example we will bond eth1 and eth2 interfaces and create vlan trunks with vid 8, 64 and 96. The gateway (ISP) is on eth0.
auto eth0 iface eth0 inet dhcp auto bond0 # use manual because the bond0 interface should not have any ip. # set your largest MTU here. iface bond0 inet manual bond-slaves eth1 eth2 post-up ip link set dev bond0 mtu 9000 # uses "default" MTU of 9000 auto bond0.8 iface bond0.8 inet static address 10.65.8.1 netmask 255.255.255.0 # uses standard MTU of 1500 auto bond0.64 iface bond0.64 inet static address 10.65.64.1 netmask 255.255.255.0 mtu 1500 auto bond0.96 iface bond0.96 inet static address 10.65.96.1 netmask 255.255.255.0