1

For my local environment i'm trying to add multiple vlans to my KVM server. I want to use one nic for management and the other for vlan tagging.

Initial installation was made by following https://www.cyberciti.biz/faq/how-to-install-kvm-on-centos-8-headless-server/

Afterwards I tried to add new vlan by this guide https://fardog.io/blog/2020/11/08/centos-and-kvm-single-interface-multiple-vlans-for-guests/

Have tried several nmcli commands to connect cards to correct vlan, no matter what it seems that vlan are not accessible on my server.

Using macvtap is possible and works for the most, I also need to have access between virtual maskines and that seems to not work on macvtap.

Anyone that has configured KVM with multiple vlans on centos 8 that can help me?

thborge83
  • 11
  • 1
  • Exactly how did you configure your virtual networks? – Michael Hampton Jul 11 '21 at 12:25
  • I used eno2 instead of eno1 when configuring them, first I tried exactly as the on in the first link, but changed to my local IP. – thborge83 Jul 11 '21 at 18:50
  • I used eno2 instead of eno1 when configuring them, first I tried exactly as in the first link, but changed to my local IP. Made a br0 config file, and changed eno2 to be using br0 as bridge So I got the br0 up and running, and could ping my br0 interface, but not my br0.20 that I made for vlan 20. Then I removed all of the configuration that was made manually, and then tried as the second link to see if it worked as it was described but nothing better luck there. The last test was with nmcli commands, similarly made the same as the first step. Ended up with eno2.xx config files only – thborge83 Jul 11 '21 at 18:57
  • @thborge83 update your question instead of repeating your self. – djdomi Jul 21 '21 at 07:23

1 Answers1

1

Frankly, I'm not a fan of NM, especially since the regular RHEL config files do the job (at least in this particular case) quite well.

The idea is as follows:

[NIC] -> [VLAN X] -> [bridgeX] -> [VM]
 L-----> [VLAN Y] -> [bridgeY] -> [VM]

In RHEL/CentOS/etc this would look as follows:

The base NIC eth0 (can also be a bond) /etc/sysconfig/network-scripts/ifcfg-eth0:

TYPE=Ethernet
BOOTPROTO=none
NAME=eth0
DEVICE=eth0
ONBOOT=yes
NM_CONTROLLED=no

The VLAN tagged interface: /etc/sysconfig/network-scripts/ifcfg-eth0.100

DEVICE=eth0.100
BOOTPROTO=none
ONBOOT=yes
VLAN=yes  #this is the VLAN setting really
BRIDGE=br100 #the bridge we will attach on top of this tagged interface

You can repeat this one for any VLAN tag just changing the tag number.

The bridge setup for each VLAN: /etc/sysconfig/network-scripts/ifcfg-br100

DEVICE=br100
TYPE=Bridge
DELAY=0 #important if you intend to live migrate VMs between multiple hosts
STP=off
ONBOOT=yes
IPADDR=1.2.3.4 #IP in the VLAN 100
NETMASK=x.x.x.x
GATEWAY=x.x.x.x
BOOTPROTO=none
MTU=1500
NM_CONTROLLED=no
DNS1=x.x.x.x

Now any VM that uses the br100 bridge will have all it's traffic tagged with tag 100.

dyasny
  • 18,802
  • 6
  • 49
  • 64