You are not logged in.

#1 2018-06-04 16:02:13

awado
Member
Registered: 2014-02-13
Posts: 10

[Solved] Trying to add VLAN by a virtual interface

Hi!

I'm struggling with all the different ways of setting up VLAN that are given by various tutorials. So what's the proper ays of doing it in the most recent version of Arch Linux.

There's a working ethernet port eno1. I want to add eno1.100 as virtual interface at boot time. I tried it by setting up a systemd-networkd.service environment, but that screws up my entire networking as it is not managing networking by default. eno1 is setup by /etc/conf.d/net-conf-eno1:

address=192.168.70.2
netmask=24
broadcast=192.168.70.255
gateway=192.168.70.1

A manual setup works until reboot:

ip link add link eno1 name eno1.100 type vlan id 100

Last edited by awado (2018-06-11 14:13:11)

Offline

#2 2018-06-04 16:07:13

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [Solved] Trying to add VLAN by a virtual interface

awado wrote:

I tried it by setting up a systemd-networkd.service environment, but that screws up my entire networking as it is not managing networking by default.

Well what are you using to manage your networking then? The answer will be specific to the software you are using.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2018-06-04 21:22:57

awado
Member
Registered: 2014-02-13
Posts: 10

Re: [Solved] Trying to add VLAN by a virtual interface

Okay, now I got it working. To share my insights:

Your question led me to some investigations. I thought it was the networking.service, which managed the network. But it didn't. At the very beginning of my Arch Linux install I created the mentioned conf.d file, which sets up eno1 with a static IP. This worked out of the box, with this service unit:

nano /etc/conf.d/net-conf-eno1

address=192.168.70.2
netmask=24
broadcast=192.168.70.255
gateway=192.168.70.1


nano /etc/systemd/system/network@.service

[Unit]
Description=Network startup (%i)
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/net-conf-%i
ExecStart=/sbin/ip link set dev %i up
ExecStart=/sbin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i
ExecStart=/sbin/ip route add default via ${gateway}
ExecStop=/sbin/ip addr flush dev %i
ExecStop=/sbin/ip link set dev %i down

[Install]
WantedBy=multi-user.target

I did not want to switch to systemd-networkd as shown in some tutorials. The setup should be kept simple. (So this approach might not be recommendable if you plan to switch in the future.) I want to use the VLANs for virtual machines. So I don't need a static IP address or DHCP on the host OS side. This is done within the VMs. Therefore I can start a simple service unit for VLAN configuration:

nano /etc/systemd/system/vlan.service

[Unit]
Wants=network.target
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/bin/ip link add link eno1 name eno1.100 type vlan id 100
ExecStart=/usr/bin/ip link add link eno1 name eno1.200 type vlan id 200
ExecStart=/usr/bin/ip link set dev eno1.100 up
ExecStart=/usr/bin/ip link set dev eno1.200 up

[Install]
WantedBy=multi-user.target

I only have to enable that unit via systemctl. Then it gets called at boot time.

Offline

Board footer

Powered by FluxBB