LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS
User Name
Password
CentOS This forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.

Notices


Reply
  Search this Thread
Old 06-16-2017, 08:20 AM   #1
robertkwild
Member
 
Registered: Feb 2015
Posts: 382

Rep: Reputation: Disabled
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
 
Old 03-23-2018, 07:23 PM   #2
al5
LQ Newbie
 
Registered: Mar 2018
Posts: 2

Rep: Reputation: Disabled
Quote:
Originally Posted by robertkwild View Post
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

Last edited by al5; 03-23-2018 at 07:24 PM.
 
Old 03-23-2018, 09:05 PM   #3
robertkwild
Member
 
Registered: Feb 2015
Posts: 382

Original Poster
Rep: Reputation: Disabled
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

Last edited by robertkwild; 03-23-2018 at 09:08 PM.
 
Old 03-25-2018, 09:43 AM   #4
al5
LQ Newbie
 
Registered: Mar 2018
Posts: 2

Rep: Reputation: Disabled
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
 
Old 02-16-2020, 07:25 AM   #5
dinesh1985
LQ Newbie
 
Registered: Feb 2020
Posts: 1

Rep: Reputation: Disabled
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] VLANs and parent interface Pkuutn Linux - Networking 2 08-05-2015 11:31 AM
KVM guest with 2 network interfaces in diferrent VLANs tklima Linux - Networking 1 07-20-2014 02:26 PM
iptables NAT to multiple vlans? ACiD GRiM Linux - Server 0 03-26-2009 12:24 AM
bonding and vlans. Bonding a vlan interface vs applying vlans to a bond interface JasonCzerak Linux - Networking 0 09-11-2008 09:59 AM
Linux - multiple VLANS on eth0 john.morris Linux - Networking 3 12-10-2005 07:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS

All times are GMT -5. The time now is 01:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration