4km3/docker-dnsmasq

Can't get it to work as DHCP server

Closed this issue · 4 comments

jwulf commented

First of all, thanks for this great image! It's changed the way I build my images. They've all gone on an Alpine Linux diet.

I can't get the container to work as a DHCP server though. It works fine as a DNS server on port 53 on the host machine, however there is nothing listening on port 67/udp, which is where I'm expecting DHCP to be. The host machine has a static IP of 192.168.2.2.

I start the container like this:

docker run -d --name dns -p 192.168.2.2:67:67/udp -p 192.168.2.2:53:53/udp sitapati/dns

With the container running, I use dhcping 192.168.2.2, but get "no answer". telnet 192.168.2.2 67 returns "Connection refused".

There is no firewall on this machine, which is running Ubuntu 16.04.

My dnsmasq.conf file in the container looks like this:

interface=eth0
user=root
domain-needed
bogus-priv
no-resolv
local=/mydomain.io/
no-poll
server=8.8.8.8
server=8.8.4.4
no-hosts
addn-hosts=/etc/dnsmasq_static_hosts.conf
expand-hosts
domain=mydomain.io
dhcp-range=192.168.2.10,192.168.2.250,255.255.255.0,192.168.2.255,5m
# Have windows machine release on shutdown
dhcp-option=vendor:MSFT,2,1i
# No default route
dhcp-option=3

Things I've thought of/tried:

  • Is it because eth0 in the container has an address on a completely different subnet? (docker inspect tells me it's 172.17.0.2 on the bridged interface)
  • does it need to use --net host? I tried that, and it still didn't work.

What happens if you remove interface and add listen-address=0.0.0.0? Also, after a quick skim of http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html, the first sentence of the bind-interfaces option could be relevant.

jwulf commented

I think it's because libvirt starts a dnsmasq instance to service the docker container network:

http://wiki.libvirt.org/page/Libvirtd_and_dnsmasq

That's bound to the main physical interface.

¯_(ツ)_/¯ If that is the case then it isn't really an issue of this image.

Closing as it seemed like a conflict with the libvirt DHCP. Re-open if you otherwise think it is an issue with this image.