In this post, It will be demonstrated how to create Bridges and VLANs to be used on KVM. In my other post, I already implemented VLANs using Openvswitch.
Physical host that I used on this lab is Linux Mint 20 (Ulyana).
Netplan is a utility for easily configuring networking on a GNU/Linux systems. You can easily create network configuration with YAML syntax. Netplan reads network configuration from
/etc/netplan/*.yaml which are written by administrators, installers, cloud image instantiations, or other OS deployments.
Before starting any configuration you have to load the module 8021q, if it is not loaded. For Linux Mint 20 it is loaded automatically on boot.
Creating a netplan configuration File:
Create a file in the /etc/netplan/bridge.yaml and copy the content below. Of course you can change the configuration based on your needs.
network: version: 2 renderer: networkd ethernets: enp5s0: dhcp4: no bridges: VSW0: interfaces: [ enp5s0 ] dhcp4: false dhcp6: false parameters: forward-delay: 0 stp: true br10: interfaces: [ vlan.10 ] dhcp4: false dhcp6: false addresses:  parameters: forward-delay: 0 stp: true br20: interfaces: [ vlan.20 ] dhcp4: false dhcp6: false addresses:  parameters: forward-delay: 0 stp: false br100: interfaces: [ vlan.100 ] dhcp4: false dhcp6: false addresses:  parameters: forward-delay: 0 stp: true vlans: vlan.10: id: 10 link: enp5s0 dhcp4: false dhcp6: false vlan.20: id: 20 link: enp5s0 dhcp4: false dhcp6: false vlan.100: id: 100 link: enp5s0 dhcp4: false dhcp6: false
After netplan config created , syntax check should be made before apply the configuration.
gokay@tesla:~$ sudo netplan try Please carefully review the configuration and use 'netplan apply' directly.
gokay@tesla:~$ sudo netplan apply
Once the configuration applied, bridges and vlan interfaces should be created. You can check it with the utility brctl.
gokay@tesla:~$ sudo brctl show bridge name bridge id STP enabled interfaces VSW0 8000.244bfe0502f8 yes enp5s0 br10 8000.244bfe0502f8 yes vlan.10 br100 8000.244bfe0502f8 yes vlan.100 vnet0 br20 8000.244bfe0502f8 no vlan.20
You can simply see the Figure below to understand easily how our physical host looks like now. In this post, you can ignore the Physical switch and Router part, as we did not do any Physical switch and Router configuration for Intervlan routing.
Once netplan configuration has been completed, you can check on virt-manager if you are able to see the bridges(VLANs)
On the VM, I just ping the IP that does not allocated by any machine to create a Broadcast package to sniff via Wireshark.
I pinged to 10.5.100.23 from 10.5.100.10(VM) .
As you see in the figure above, You can see the frame 802.1q section. Which means vlan configured successfully.