0

I have a Ubuntu Desktop, with Libvirt based Virtual Machines setup over virbr0 bridge. Currently libvirt's default DHCP server (dnsmasq) provides IP address assignments.

 root@ngadre-Inspiron-3542:/home/ngadre# virsh net-dumpxml default
<network>
  <name>default</name>
  <uuid>0cc9820a-aa74-4456-88e9-ee04256effcb</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:23:0b:1b'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254'/>
    </dhcp>
  </ip>
</network>

root@ngadre-Inspiron-3542:/home/ngadre/route-sim# brctl show virbr0
bridge name bridge id       STP enabled interfaces
virbr0      8000.525400230b1b   yes     virbr0-nic
                                         vnet0 --> NIC of VM connected to bridge

I have a dhcp server on my host ubuntu running on enp7s0

enp7s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether b8:2a:72:cc:0a:db  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

I would like this DHCP server to provide IP to VM guests instead of the libvirt default.

How to achieve this.

  • Sounds like you want to directly bridge the VM net with the hosts LAN – hardillb Feb 20 at 10:54
  • 1
    Halfway down this doc: wiki.libvirt.org/page/Networking -> Bridged_networking_(aka_"shared_physical_device") – hardillb Feb 20 at 10:56
  • Hi Hardillb, thanks for the link, information. I am able to attach the new bridge br0 to my VM. If you wish to keep your answer in comments, i'd like to ask another question in continuation. – Haswell Feb 22 at 16:42
  • 1
    I've added it as a real answer. If you have a follow up question ask and new one and link to this one if needed for reference. – hardillb Feb 22 at 16:51
1

As mentioned in the comments.

It sounds like you need to bridge your VM network with the local physical ethernet device. Details about bridged networks can be found in the libvirt docs here

You can configure the guest to use the bridged interface with:

<interface type='bridge'>
  <source bridge='br0'/>
  <mac address='00:16:3e:1a:b3:4a'/>
  <model type='virtio'/>   # try this if you experience problems with VLANs
</interface>
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.