VLAN: Difference between revisions

From Alpine Linux
No edit summary
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This article shows how to configure a network interface as an IEEE 802.1q VLAN trunk.
This article shows how to configure a network interface as an IEEE 802.1q VLAN trunk.
__TOC__


{{Note| Alpine Linux v2.4 or later is required}}
{{Note| Alpine Linux v2.4 or later is required}}
Line 15: Line 17:
gateway 192.168.0.1
gateway 192.168.0.1
</pre>
</pre>
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.
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:
Alternativly with vlan8 over eth0:
<pre>
<pre>
auto vlan8
auto vlan8
Line 27: Line 29:
</pre>
</pre>


In those examples a static ip address was used but it works with dhcp as well.
A static ip address was used in the examples shown above, but dhcp can be used as well.


== Example with vlans over bonding ==
== Example with bridges associated 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.
This serves as an example of some of the more complicated networking possible. Particularly, this would work well for a hypervisor attached to a dedicated storage VLAN. Less complicated implementations can be achieved by merely removing the non-applicable parts.
<pre>
<pre>
auto eth0
auto lo
iface eth0 inet dhcp
iface lo inet loopback


auto bond0
auto bond0
# use manual because the bond0 interface should not have any ip.
iface bond0 inet manual
iface bond0 inet manual
bond-slaves eth1 eth2
bond_slaves eth0 eth1
# bring up the vlans with 'ifup bond0'
bond_mode 802.3ad
up ifup bond0.8
bond_miimon 100
up ifup bond0.64
bond_xmit_hash_policy layer2+3
up ifup bond0.96
post-up ip link set dev bond0 mtu 9000


down ifdown bond0.96
iface bond0.1 inet manual
down ifdown bond0.64
down ifdown bond0.8


# no auto since ifup bond0 will bring this up
auto br1
iface bond0.8 inet static
iface br1 inet static
address 10.65.8.1
address 192.168.1.196
netmask 255.255.255.0
netmask 255.255.255.0
gateway 192.168.1.1
bridge_ports bond0.1
bridge_stp off
bridge_fd 0.0
post-up ip link set dev bond0.1 mtu 1500


iface bond0.64 inet static
iface bond0.10 inet manual
address 10.65.64.1
netmask 255.255.255.0
 
iface bond0.96 inet static
address 10.65.96.1
netmask 255.255.255.0


auto br10
iface br10 inet static
address 192.168.10.1
netmask 255.255.255.0
bridge_ports bond0.10
bridge_stp off
bridge_fd 0.0
</pre>
</pre>


[[Category:Networking]]
[[Category:Networking]]

Revision as of 06:39, 23 July 2021

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.

Alternativly 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

A static ip address was used in the examples shown above, but dhcp can be used as well.

Example with bridges associated with VLANs over bonding with differing MTUs on the various VLANs

This serves as an example of some of the more complicated networking possible. Particularly, this would work well for a hypervisor attached to a dedicated storage VLAN. Less complicated implementations can be achieved by merely removing the non-applicable parts.

auto lo
iface lo inet loopback

auto bond0
iface bond0 inet manual
bond_slaves eth0 eth1
bond_mode 802.3ad
bond_miimon 100
bond_xmit_hash_policy layer2+3
post-up ip link set dev bond0 mtu 9000

iface bond0.1 inet manual

auto br1
iface br1 inet static
address 192.168.1.196
netmask 255.255.255.0
gateway 192.168.1.1
bridge_ports bond0.1
bridge_stp off
bridge_fd 0.0
post-up ip link set dev bond0.1 mtu 1500

iface bond0.10 inet manual

auto br10
iface br10 inet static
address 192.168.10.1
netmask 255.255.255.0
bridge_ports bond0.10
bridge_stp off
bridge_fd 0.0