Configuring a trunk network without native VLAN on Ubuntu

I had to deal with systemd nonsense today because I’m trying to deploy something cool under Ubuntu. Usually I don’t have to deal with systemd so I thought it may be worth documenting for me to remember.

So, first of all. Doing the first attempt on-the-fly to know networking actually works. In this case I will use vconfig to create the vlan interface, ip for adding the address to the new device and route for the gateway.

For this example I want to use the interface enp9s0f1, the VLAN 205, as IP address I want 10.200.205.22 and my gateway is 10.200.205.254.

# vconfig add enp9s0f1 205
# ip addr add 10.200.205.22/24 dev enp9s0f1.205
# route add default gw 10.200.205.254
# ip link set dev enp9s0f1 up
# ip link set dev enp9s0f1.205 up

Once this is done, you should be able to reach the server thru the network. You might want to setup your DNS too, go to resolved configuration and add the following lines (or modify if already there).

/etc/systemd/resolved.conf

[Resolve]
DNS=8.8.8.8
FallbackDNS=8.8.4.4

Restart systemd-resolved by doing systemctl restart systemd-resolved. Once everything works as it should time to make it persistent.

Go to /etc/systemd/network and you will have to create 3 files. One for the carrier and two for the VLAN interface.

/etc/systemd/network/enp9s0f1.network

[Match]
Name=enp9s0f1

[Network]
VLAN=enp9s0f1.205

Once we specify that we will use a VLAN using enp9s0f1.205 device, we will create enp9s0f1.205.netdev and enp9s0f1.205.network to configure that interface as it should. netdev will specify that it is a VLAN and the ID while the network file will provide the static configuration of the address.

/etc/systemd/network/enp9s0f1.205.netdev

[NetDev]
Name=enp9s0f1.205
Kind=vlan

[VLAN]
Id=205

/etc/systemd/network/enp9s0f1.205.network

[Match]
Name=enp9s0f1.205

[Network]
Description=”VLAN 205″
Address=10.200.205.22/24
Gateway=10.200.205.254

After doing this make sure to have systemd-networkd and systemd-resolved enabled for next boot (systemctl enable …), perform a reboot and everything should be good to go :).

And well this was my first and not pleasant approach to systemd-networkd and systemd-resolved and so far I hated how they work.

If you know a better way to fulfill this, feel free to leave a comment!

Leave a Reply

Your email address will not be published. Required fields are marked *