1

I'm using dnsmasq as DHCP server in VM environment. But It didn't working. I disabled basic DHCP feature in libvirt.

<network>
  <name>default</name>
  <uuid>84da0678-e56d-8fc2-6f8b-e8eba784849a</uuid>
  <forward mode='nat'/>
  <bridge name='virbr0' stp='on' delay='0' />
  <mac address='52:54:00:7B:64:0B'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
  </ip>
</network>

As you can see, I removed this tag!

<dhcp>
  <range start='192.168.122.2' end='192.168.122.254' />
</dhcp> 

And I installed dnsmasq in Host machine. During installation dnsmasq, there was an error message about 127.0.0.1.(dnsmasq: failed to create listening socket for 127.0.0.1) So I commented out listen-address option, and added dhcp-range/dhcp-option options, like this.

listen-address=127.0.0.1
dhcp-range=192.168.122.100,192.168.122.200,24h
dhcp-option=option:router,192.168.122.1

That's all I've done with dnsmasq. But guest VM couldn't get IP address from host which is dnsmasq server running.

After that , I installed isc-dhcp-server instead of dnsmasq.... and it works! But I still want to use dnsmasq instead of isc-dhcp-server. Are there any helping hands?

  • I disabled host machine's firewall.
  • I've heard that libvirt basically use dnsmasq. Is this the reason why I couldn't use dnsmasq in libvirt environment?
gunsmoke
  • 51
  • 2
  • 5
  • Your config snippet does not show listen-address commented out - have you really done this ? Is dnsmasq actually running ? – user9517 May 21 '14 at 06:38
  • I've tried to use 'listen-address=127.0.0.1' and remove it, the results are the same. It didn't work. – gunsmoke May 21 '14 at 07:04
  • I found this [link](https://bugs.launchpad.net/ubuntu/+source/dnsmasq/+bug/1006898). I'm using Ubuntu 12.04, and maybe the version of dnsmasq(2.59) can make problem. I don't know exactly, but I'll try to use newer version later. – gunsmoke May 21 '14 at 07:57
  • Why are you doing this? libvirt handles dnsmasq for you, so you should allow it to do so. – Michael Hampton May 21 '14 at 13:27
  • You're right. But I want to show how DHCP and DNS server work using VM environments. – gunsmoke May 21 '14 at 14:44
  • Is `interface` specified in your config? – sciurus May 22 '14 at 23:50
  • I used interface=virbr0, because virbr0 is the interface listening from VM. But I failed. I read libvirt official manual, and realized If I want to use my own dnsmasq, I had to turn off dnsmasq which used in libvirt. So I stopped virtual network "default" and manually used virbr0. But dnsmasq still didn't work. – gunsmoke May 25 '14 at 13:09

1 Answers1

1

Libvirt does indeed use DNSMasq to handle DHCP. If you're trying to do some advanced configs with DNSMasq, you need to make sure Libvirt is not interfering (removing the DHCP option from your config would work).

Your actual issue appears to be caused by the 'listen-address' statement. DNSMasq requires a valid IP address in the subnet you're trying to assign to. You should configure it to use an IP in the 192.168.122.0/24 range. If you don't do this, it won't actually be able to assign any IP addresses.

devicenull
  • 5,622
  • 1
  • 26
  • 31