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?
7
  • Your config snippet does not show listen-address commented out - have you really done this ? Is dnsmasq actually running ?
    – user9517
    May 21, 2014 at 6: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, 2014 at 7:04
  • I found this link. 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, 2014 at 7:57
  • Why are you doing this? libvirt handles dnsmasq for you, so you should allow it to do so. May 21, 2014 at 13:27
  • You're right. But I want to show how DHCP and DNS server work using VM environments.
    – gunsmoke
    May 21, 2014 at 14:44

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .