Disable kvm dnsmasq and force VMs to get IP address from DSL router

Hello Community

i have just added a KVM linux host to my home network in preparing for the Rhcsa. This is a dell power edge 610 in my basement rack. On this I have 3 linux VMs. They were issued this weird 192.168.122.0/24 IP address because of Libvirt and Dnsmasq.

I also have other linux and Windows workstation connected on the same network. They are all hardwired to a netgear switch which goes to the DSL modem.

Accessing the VMs directly from the Host in the basement, I can ping other workstation with no issues. However if I move to another workstation, I can ping the host, but not the VMs.

I can see the VMs are in a different sub-net as my other workstation and this is because of the libvirt and dnsmasq.

How can I disable this dnsmasq and force the VMs to acquire IP address settings from my DSL router?

Is this even possible to do without messing up the VMs

If you don’t want to mess up with VM ip address, set up NAT. The procedure is simple:

  1. Change DHCP range and make room for static IP (see https://www.cyberciti.biz/faq/linux-kvm-libvirt-dnsmasq-dhcp-static-ip-address-configuration-for-guest-os/ )
  2. Assign a static IP to your VM and reboot
  3. Set up NAT on host (see https://www.cyberciti.biz/faq/kvm-forward-ports-to-guests-vm-with-ufw-on-linux/)

It is a bit complicated but doable.

Getting an IP from DSL router

Another option is to define br0 bridge with your LAN (see https://www.cyberciti.biz/faq/rhel-linux-kvm-virtualization-bridged-networking-with-libvirt/) . Once done set up br0 to VM using virsh and now you can get IP directly from your DSL router. To do this, shutdown the vm and run:

virsh edit --domain {vm-name-here}

Look for bridge type, say:

    <interface type='bridge'>
      <mac address='52:54:00:36:ec:cf'/>
      <source bridge='virbr0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

Change virbr0 (which is the default for you) to br0:

      <model type='br0'/>

Save and close the file. Restart services and start vm.


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki