LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 06-25-2021, 04:46 PM   #1
browny_amiga
Member
 
Registered: Dec 2001
Location: /mnt/UNV/Mlkway/Earth/USA/California/Silicon Valley
Distribution: Kubuntu, Debian Buster Stable, Windoze 7
Posts: 684

Rep: Reputation: 56
KVM: How to make VM get IP from same DHCP as host?


Hi,

I have several VMs on KVM with virtual machine manager that I don't want to use NAT with, I want them to get a IP from the same source as the host machine, from the external DHCP. For this purpose, I want to do level 2 bridging, so the virsh networking "switch" or interface is directly bridged with the physical NIC of the host OS. This has so far not worked, when setting up the bridge, it keeps asking me for an IP and range, but Level 2 bridging has no IP, level 2 is below IP and just lets all traffic through.
I think that people today confuse what a bridge is and lump together other technologies to join virtual NICs.

I have noticed that this is super simple when you use Microsoft HyperV or VirtualBox, but pretty difficult with KVM and virtual machine manager. There is hardly any documentation and nobody seems to use KVM much at all.

Right now, when I use KVM to run my VMs, they get a IP from the internal virsh DHCP and are not reachable from external machines, which is a problem.

Last edited by browny_amiga; 06-25-2021 at 04:48 PM.
 
Old 06-25-2021, 07:58 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
I agree that VMM is somewhat less comfortable than VirtualBox, but what you say does not make much sense to me.

Quote:
Originally Posted by browny_amiga View Post
I want to do level 2 bridging, so the virsh networking "switch" or interface is directly bridged with the physical NIC of the host OS. This has so far not worked, when setting up the bridge, it keeps asking me for an IP and range.
What keeps you asking? How exactly did you set up the virtual network?
Quote:
Right now, when I use KVM to run my VMs, they get a IP from the internal virsh DHCP and are not reachable from external machines, which is a problem.
If they are bridged, they are connected to the same network as the other devices. Except if the VM host blocks or otherwise manipulates traffic. It seems your VMs are not bridged.

To help you, I'd like to see the output of
Code:
virsh domiflist VM
where VM is one of those VMs that you have trouble with.
 
Old 06-25-2021, 08:43 PM   #3
browny_amiga
Member
 
Registered: Dec 2001
Location: /mnt/UNV/Mlkway/Earth/USA/California/Silicon Valley
Distribution: Kubuntu, Debian Buster Stable, Windoze 7
Posts: 684

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by berndbausch View Post
I agree that VMM is somewhat less comfortable than VirtualBox, but what you say does not make much sense to me.


What keeps you asking?
When I read the instructions on how to setup bridges via different means, it often has instructions to set an IP for the bridge, which does not make sense to me.
Quote:

How exactly did you set up the virtual network?
That is how the questions start, I use virt-manager on Debian 10 and I'm confused on how I can get a level 2 bridged NIC in my VM that is directly connected to the host interface.
I have to admit that I don't have much experience setting up virtual networks on KVM via virsh, virt-manager doesn't offer many possibilities.
I keep coming across macvtap, which seems to offer bridge functionality. That seems to use a more direct connection via the virtual NIC for just one VM, while there is another possibility to define a whole virtual network.

Quote:


If they are bridged, they are connected to the same network as the other devices. Except if the VM host blocks or otherwise manipulates traffic. It seems your VMs are not bridged.
Yeah, I don't think it is bridged right now.
Quote:

To help you, I'd like to see the output of
Code:
virsh domiflist VM
where VM is one of those VMs that you have trouble with.
I'm honestly pretty confused on how to setup a virtual network on KMV / QEMU, it is likely not VM specific, but applys to the whole virtual network.
I basically just want that VM to get attached to my host NIC like it was physically connected to the VM and when it sends out DHCP requests, it will get an IP the same way that the host gets one.
I actually want to use KVM and avoid virtualbox as it is the built in solution on Linux. And the VMs also work pretty well, except I have always struggled with the networking. Normally, the VMs seem to be connected to use NAT to get out to the external net, but I need these VMs to be accessible from outside (which NAT normally blocks)

Last edited by browny_amiga; 06-25-2021 at 08:47 PM.
 
Old 06-27-2021, 11:58 AM   #4
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,141

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
Create a bridge on the host then point at that.
 
Old 06-27-2021, 08:48 PM   #5
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by browny_amiga View Post
When I read the instructions on how to setup bridges via different means, it often has instructions to set an IP for the bridge, which does not make sense to me.
Without knowing what you did to set up the network, nobody can help you. Try providing information instead of repeatedly stating that you are confused.
 
Old 06-27-2021, 09:32 PM   #6
browny_amiga
Member
 
Registered: Dec 2001
Location: /mnt/UNV/Mlkway/Earth/USA/California/Silicon Valley
Distribution: Kubuntu, Debian Buster Stable, Windoze 7
Posts: 684

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by berndbausch View Post
Without knowing what you did to set up the network, nobody can help you. Try providing information instead of repeatedly stating that you are confused.
I did not set up any network. I used the default network that was already established. That is for NAT, which does not work for my use case, it sets up a local network on the VM host that is 192.168.122.0/24, including a local DHCP for it. 192.168.122.1/24 is not accessible from outside of this VM host (192.168.1.220)

I have quite a bit of experience in TCP/IP networking, but bridging is something I have never been able to get working.
I basically don't know how you setup networking with virsh, what the options are etc. My goal is to get several guest VMs to use the DHCP server on router 192.168.1.1 (serving network 192.168.1.1/24) to get an IP that is on the same network as the VM host (192.168.1.220). I'm trying to use bridging for that, I don't know if that is the recommended way, but I don't see how DHCP discovery requests from the guest VMs could otherwise arrive at 192.168.1.1 and then have a DHCPOFFER traverse back to the guest VM. The guest VMs will all be on several different physical VM Hosts (all on network 192.168.1.1/24) that all need to get IPs in network 192.168.1.1/24

When I take a physical laptop and plug it via ethernet, it will get an IP on network 192.168.1.1/24, I need all the guest VMs to get IPs on the exact same network via the same DHCP.

This hope I have expressed myself clearly, on the risk of having included redundant and obvious details.
 
Old 06-27-2021, 11:03 PM   #7
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,141

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
https://wiki.debian.org/BridgeNetworkConnections

Do that. Your mistake is you are trying to use virsh to run the networking. You need to bypass it. Point the VM at br0 (or whatever you call it) in virt-manager. When this is done the VMs are just another machine on the lan.
 
Old 07-02-2021, 08:10 PM   #8
browny_amiga
Member
 
Registered: Dec 2001
Location: /mnt/UNV/Mlkway/Earth/USA/California/Silicon Valley
Distribution: Kubuntu, Debian Buster Stable, Windoze 7
Posts: 684

Original Poster
Rep: Reputation: 56
Yes, that worked. I just created the bridge outside virsh, on Linux, added the ethernet interface to it, set that to promisc and set the IP on the bridge interface (I was confused on how the bridge works on the different OSI layers), then adding the virtual machine to that bridge does the trick. The default gateway still has to be changed.
 
  


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
KVM on Redhat 5.7: KVM can ping outside network, outside network can't ping KVM svandyk Linux - Networking 1 09-23-2011 06:45 AM
[Debian/Qemu/KVM] Why qemu --enable-kvm works but not kvm directly? gb2312 Linux - Virtualization and Cloud 2 03-21-2011 02:05 PM
VMWare's bridging vs Window's bridging - routing is messed up when Windows bridging brenan99 General 0 05-04-2008 10:24 PM
emacs in run level 3 then switch to X (level 7) then back to level 3 dsoliver Slackware 3 09-01-2006 03:31 AM
Bridging+Bonding for Bridging+HA+Load Balancing? kartheekpn Linux - Networking 0 08-13-2006 02:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 11:07 PM.

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