1

I want to use libvirt network NAT configuration.

libvirt says https://wiki.libvirt.org/page/Virtual_network_%22default%22_has_not_been_started:

"1) If you're not actually using dnsmasq on the physical machine to serve DHCP for the physical network, you should just disable dnsmasq completely"

that corresponds to my context, so I stop and disable dnsmasq in the host system.

in qemu system:

virsh # net-edit default

<name>default</name>

<uuid>b6ef8506-d4c7-4bba-9fe7-8f971ea87d10</uuid>

<forward mode='nat'>

<nat>

<port start='1024' end='65535'/>

</nat>

</forward>

<bridge name='virbr0' stp='on' delay='0'/>

<mac address='52:54:00:06:86:de'/>

<domain name='circus.net'/>

<ip address='192.168.122.1' netmask='255.255.255.0'>

<dhcp>

<range start='192.168.122.2' end='192.168.122.10'/>

</dhcp>

</ip>

</network>

I start default network:

virsh # net-start default
Network default started

virsh # net-list
Name State Autostart Persistent
----------------------------------------------------------
default active no yes

I start guests S0 and S1

virsh # start S0
Domain S0 started

virsh # start S1
Domain S1 started

virsh # list
Id Name State
----------------------------------------------------
1 S0 running
2 S1 running

but DHCP does not seem to work:

virsh # net-dhcp-leases default
Expiry Time MAC address Protocol IP address Hostname Client ID or DUID
-------------------------------------------------------------------------------

on the host machine:

ping: S1: Name or service not known

what I have tried:

in virt-manager

hostnamectl set-hostname server1
hostnamectl set-hostname server0

virsh # shutdown S0
virsh # shutdown S1
virsh # net-destroy default

on the host:

tcpdump -i virbr0

in qemu:

virsh # net-start default
virsh # start S0
virsh # start S1

tcpdump does not see anything coming to virbr0

my question is: how to have DHCP working in this case?

additional questions:

1.it is said, in libvirt, nat conf should work out ot the box (default conf), nothing to do. what does 'out of the box' mean exactly? both S1 and S0 here have,by default, FQDN set to localhost.localdomain , so how libvirt DHCP make the distinction between S0 & S1?

2.If I want to customize my dnsmasq config (for instance, sthg like log-facility=/var/log/dnsmasq.log), where is the conf file? not in /etc/dnsmasq.conf or in /etc/dnsmasq.d/anyname.conf as dnsmasq does not work on the host?

  • What do you mean that you "stop and disable dnsmasq in the host system" ? Exactly what did you do? – Michael Hampton Aug 25 '20 at 2:08
0

I had the same issue on a Debian system and am posting a solution in case it helps, or if anyone can improve on it that would be great :)

Host-to-guest connectivity works after adding the following to the guest domain XML file:

<interface type='bridge'>
  <source bridge='virbr0'/>
  <model type='virtio'/>
</interface>

That created a previously unseen network interface in the guest system. Then I ran dhclient on the interface inside the guest VM and it got a 192.168.122.x address with ports accessible to the host system.

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.