Vlan

From Alpine Linux
Jump to: navigation, search

This article shows how to configure a network interface as an IEEE 802.1q VLAN trunk.

Contents


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

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.
iface bond0 inet manual
	bond-slaves eth1 eth2
	# bring up the vlans with 'ifup bond0'
	up ifup bond0.8
	up ifup bond0.64
	up ifup bond0.96

	down ifdown bond0.96
	down ifdown bond0.64
	down ifdown bond0.8

# no auto since ifup bond0 will bring this up
iface bond0.8 inet static
	address 10.65.8.1
	netmask 255.255.255.0

iface bond0.64 inet static
	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