Christian Kujau
2019-Aug-01 02:21 UTC
[libvirt-users] libvirt/dnsmasq is not adhering to static DHCP assignments
This is basically a continuation of an older posting[0] I found, but apparently no solution has been posted. So, I'm trying to setup static DHCP leases with dnsmasq that is being started by libvirtd: ----------------------------------------------------------- $ sudo virsh net-dumpxml --network default <network> [...] <dns enable='no'/> <ip address='192.168.122.1' netmask='255.255.255.0'> <dhcp> <range start='192.168.122.130' end='192.168.122.250'/> <host mac='08:00:27:e2:81:39' name='f30' ip='192.168.56.139'/> ----------------------------------------------------------- And the domain is indeed being started with that hardware address: ----------------------------------------------------------- $ virsh dumpxml --domain f30 | grep -B1 -A3 mac\ a <interface type='bridge'> <mac address='08:00:27:e2:81:39'/> <source bridge='virbr0'/> <target dev='tap0'/> <model type='virtio'/> ----------------------------------------------------------- But for some reason the domain gets a different address assigned, albeit from the correct DHCP pool: ----------------------------------------------------------- $ ssh 192.168.122.233 "ip addr show" [...] 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 08:00:27:e2:81:39 brd ff:ff:ff:ff:ff:ff inet 192.168.122.233/24 brd 192.168.122.255 scope global dynamic enp1s0 ----------------------------------------------------------- See below for even more details. I've removed the virbr0.status file, restarted the network, still it gets this .233 address instead of the configured .139. Also, I'm not able to add a debug log to the libvirtd/dnsmasq instance, although it should be possible[1], the xmlns:dnsmasq stanza is overwritten as soon as the configuration is saved. Short of a debug (queries) log, strace on the libvirtd/dnsmasq process reveals that the client seems to request this strange IP address: 23002 19:01:59.053558 write(11, "<30>Jul 31 19:01:59 dnsmasq-dhcp[23002]: DHCPREQUEST(virbr0) 192.168.122.233 08:00:27:e2:81:39 ", 95) = 95 23002 19:01:59.054024 write(11, "<30>Jul 31 19:01:59 dnsmasq-dhcp[23002]: DHCPACK(virbr0) 192.168.122.233 08:00:27:e2:81:39 f30", 94) = 94 So I restarted the dhclient process in the domain (a freshly installed Fedora 30), removed all state files with "192.168.122.233" in them, but still the domains gets assigned the .233 instead of the .139 address. The next step would be to disable libvirtd/dnsmasq altogether and run my own dnsmasq instance, but I wanted to avoid that. Any idead on where to look next? Thanks, Christian. [0] https://www.redhat.com/archives/libvirt-users/2017-October/msg00070.html [1] https://libvirt.org/formatnetwork.html#elementsNamespaces # cd /var/lib/libvirt/dnsmasq/ # grep -r . . | fgrep -v \# ./default.conf:strict-order ./default.conf:port=0 ./default.conf:pid-file=/var/run/libvirt/network/default.pid ./default.conf:except-interface=lo ./default.conf:bind-dynamic ./default.conf:interface=virbr0 ./default.conf:dhcp-range=192.168.122.130,192.168.122.250,255.255.255.0 ./default.conf:dhcp-no-override ./default.conf:dhcp-authoritative ./default.conf:dhcp-lease-max=121 ./default.conf:dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile ./default.hostsfile:08:00:27:e2:81:39,192.168.56.139,f30 ./virbr0.status:[ ./virbr0.status: { ./virbr0.status: "ip-address": "192.168.122.233", ./virbr0.status: "mac-address": "08:00:27:e2:81:39", ./virbr0.status: "hostname": "f30", ./virbr0.status: "client-id": "ff:27:e2:81:39:00:04:8c:ad:c4:7d:04:e8:4b:de:93:4b:76:d8:75:82:86:c8", ./virbr0.status: "expiry-time": 1564628519 ./virbr0.status: } ./virbr0.status:] -- BOFH excuse #40: not enough memory, go get system upgrade
Michal Privoznik
2019-Aug-02 07:24 UTC
Re: [libvirt-users] libvirt/dnsmasq is not adhering to static DHCP assignments
On 8/1/19 4:21 AM, Christian Kujau wrote:> This is basically a continuation of an older posting[0] I found, but > apparently no solution has been posted. So, I'm trying to setup static > DHCP leases with dnsmasq that is being started by libvirtd: > > > ----------------------------------------------------------- > $ sudo virsh net-dumpxml --network default > <network> > [...] > <dns enable='no'/> > <ip address='192.168.122.1' netmask='255.255.255.0'> > <dhcp> > <range start='192.168.122.130' end='192.168.122.250'/> > <host mac='08:00:27:e2:81:39' name='f30' ip='192.168.56.139'/>This is clearly a misconfiguration. 192.168.56.139 is not from 192.168.122.130/24 subnet. Libvirt should report an error in this case but it doesn't (tested right now with the current git HEAD), which is a bug. I believe if you'd s/56/122/ in the <host/> you'll find it working again. Michal
Christian Kujau
2019-Aug-09 02:06 UTC
Re: [libvirt-users] libvirt/dnsmasq is not adhering to static DHCP assignments
On Fri, 2 Aug 2019, Michal Privoznik wrote:> On 8/1/19 4:21 AM, Christian Kujau wrote: > > <range start='192.168.122.130' end='192.168.122.250'/> > > <host mac='08:00:27:e2:81:39' name='f30' ip='192.168.56.139'/> > > This is clearly a misconfiguration. 192.168.56.139 is not from > 192.168.122.130/24 subnet. Libvirt should report an error in this case but itYes, thanks for pointing this out. A little while after my posting I noticed the same but failed to post the error to the mailing list.> doesn't (tested right now with the current git HEAD), which is a bug. I > believe if you'd s/56/122/ in the <host/> you'll find it working again.Indeed, this fixed the issue. Sorry for the noise, Christian. -- BOFH excuse #353: Second-system effect.
Reasonably Related Threads
- libvirt/dnsmasq is not adhering to static DHCP assignments
- Re: libvirt/dnsmasq is not adhering to static DHCP assignments
- Re: libvirt/dnsmasq is not adhering to static DHCP assignments
- libvirt/dnsmasq is not adhering to static DHCP assignments
- Re: Automatically assign static ipv4 via dhcp to new VMs (Tim)