LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   CentOS (https://www.linuxquestions.org/questions/centos-111/)
-   -   KVM - multiple VLANS down one interface (https://www.linuxquestions.org/questions/centos-111/kvm-multiple-vlans-down-one-interface-4175608017/)

robertkwild 06-16-2017 08:20 AM

KVM - multiple VLANS down one interface
 
hi all,

i have successfully configured putting multiple VLANS down one interface so you can make different kvm guests connect to different VLANS

the trick was to add a bridge for every VLAN otherwise it wont work

DEVICE=enp2s0
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes

DEVICE=enp2s0.1
BOOTPROTO=none
ONBOOT=yes
VLAN=yes
BRIDGE=br0.1

DEVICE=enp2s0.2
BOOTPROTO=none
ONBOOT=yes
VLAN=yes
BRIDGE=br0.2

DEVICE=br0.1
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=none
DELAY=0

DEVICE=br0.2
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=none
DELAY=0

and now when you come into making a kvm guest pick either br0.1 or br0.2 ie if you want the kvm guest to either be on vlan 1 or vlan 2, once that is done give it an ip address for that vlan and boom, you can now ping it from a different machine

sorry for multiple threads about this

many thanks for everyones help

rob

al5 03-23-2018 07:23 PM

Quote:

Originally Posted by robertkwild (Post 5723354)
hi all,

i have successfully configured putting multiple VLANS down one interface so you can make different kvm guests connect to different VLANS

the trick was to add a bridge for every VLAN otherwise it wont work

DEVICE=enp2s0
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes

DEVICE=enp2s0.1
BOOTPROTO=none
ONBOOT=yes
VLAN=yes
BRIDGE=br0.1

DEVICE=enp2s0.2
BOOTPROTO=none
ONBOOT=yes
VLAN=yes
BRIDGE=br0.2

DEVICE=br0.1
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=none
DELAY=0

DEVICE=br0.2
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=none
DELAY=0

and now when you come into making a kvm guest pick either br0.1 or br0.2 ie if you want the kvm guest to either be on vlan 1 or vlan 2, once that is done give it an ip address for that vlan and boom, you can now ping it from a different machine

sorry for multiple threads about this

many thanks for everyones help

rob



Hi Rob thanks for the explanation, I got this except the IP part
I have server the following:

*Server Host ens1 , ens2 with VLAN 10 IP 10.0.0.2 Taking in consideration the bonding part on these physical ports

*1 VM with : NIC 0 VLAN 20 IP x.x.x.1/28

*1 VM with : NIC 0 VLAN 20 IP x.x.x.2/28 - NIC1 VLAN 30 IP x.x.x.3/28

where these IP's should reside ? can you please advice ? thanks

robertkwild 03-23-2018 09:05 PM

I didnt make an IP address for this NIC interface as its a bridge so all it does is literally just pass vlan traffic down it

You specify an IP address on the virtual machines you build on your hypervisor and if all goes as planned you can ping your virtual machines ip from another machine on the same network or a different network

To manage my KVM i use a different NIC and that has an IP address

Hope this makes sense

al5 03-25-2018 09:43 AM

So you mean it is independent from Host ?

as I got confused since I believe I will have to deal with 3 VLANs and 2 Physical links

bond0.10 .. br10 HOST

bond0.20 .. br20 for VM1 ,

bond0.30 .. br30 - br20 for VM2 will use 2 VLAN 20 and 30 ? I dont know if this is possible


Do I need to setup the gateway IP on the host on Br3 or all Bridge to be gateway to other VMs ?



So VM1 will use 20 1 NIC IP x.x.x.x
VM2 will use 20, 30 2 NICs IP x.x.x.x and IP x.x.x.x



Thanks

dinesh1985 02-16-2020 07:25 AM

Similar Clarification needed for IP address palcement
 
I too have the same question:

Host Part:

My Physical host box with Cent OS 7.6 has two NICs (em1 and em2) which was trunk port on DELL Switch. The NICs are bonded with bond0.

The VLAN for host machine is vlan-302 (192.168.2.12/24).

KVM part:

Two VMs has been configured inside this host. Each VM is having different VLAN than that of the host.
  1. VLAN for VM1 is vlan-303 (192.168.3.22/24) and
  1. VLAN for VM2 is vlan-304 (192.168.4.14/24).

With the above scenario, I am able to finish up to the bonding part and successfully communicating with the outside networks from the host. But I am unable to communicate from VMs and messing things up with interface files. Can someone kindly provide me the configuration files along with above IP address for a better understanding. I tried many sites and found no detailed explanation for my case.

Thanks in Advance


All times are GMT -5. The time now is 06:19 AM.