1

I'm testing configuration for my dnsmasq DHCP on my Virtualbox Debian machine. On production I want dnsmasq to provide static IP addresses to guest systems running via qemu + libvirt + openvswitch ( that one I got covered, they are running via docker and they work )

dnsmasq configuration:

# Tried both eth0 and br0 for an interface - more about it near bottom
interface=br0
domain-needed
bogus-priv
no-resolv
local=/mydomain.io/
no-poll
no-hosts
domain=mydomain.io
dhcp-range=192.168.1.129,192.168.1.254,255.255.255.128,192.168.1.255,12h
dhcp-option=3
log-queries
log-dhcp

Dockerfile:

FROM alpine:3.5 MAINTAINER dev@jpillora.com

# webproc release settings ENV WEBPROC_VERSION 0.1.7 ENV WEBPROC_URL https://github.com/jpillora/webproc/releases/download/$WEBPROC_VERSION/webproc_linux_amd64.gz

# fetch dnsmasq and webproc binary RUN apk update \
        && apk add --no-cache dnsmasq \
        && apk add --no-cache --virtual .build-deps curl \
        && curl -sL $WEBPROC_URL | gzip -d - > /usr/local/bin/webproc \
        && chmod +x /usr/local/bin/webproc \
        && apk del .build-deps

# configure dnsmasq run mkdir -p /etc/default/ RUN echo -e "ENABLED=1\nIGNORE_RESOLVCONF=yes" > /etc/default/dnsmasq

# run! CMD ["webproc","--config","/etc/dnsmasq.conf","--","dnsmasq","--no-daemon","--dhcp-broadcast"]

Commands to build and run the container:

docker build -t dnsmasq .
docker run -d  --name=dnsmasq  --volume=/data/dnsmasq.conf:/etc/dnsmasq.conf -p 53:53/udp -p 192.168.56.101:5380:8080 --net host -e "USER=foo" -e "PASS=bar" dnsmasq

docker logs dnsmasq

[webproc] 2017/01/11 07:17:09 loaded config files changes from disk
[webproc] 2017/01/11 07:17:09 agent listening on http://0.0.0.0:8080...
dnsmasq: started, version 2.76 cachesize 150
dnsmasq: compile time options: IPv6 GNU-getopt no-DBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack ipset auth no-DNSSEC loop-detect inotify
dnsmasq-dhcp: DHCP, IP range 192.168.1.129 -- 192.168.1.254, lease time 12h
dnsmasq: using local addresses only for domain mydomain.io
dnsmasq: cleared cache
dnsmasq-dhcp: no address range available for DHCP request via eth0
dnsmasq-dhcp: no address range available for DHCP request via eth0
dnsmasq-dhcp: no address range available for DHCP request via eth0

check_dhcp command ( from monitoring-plugins-basic package )

/usr/lib/nagios/plugins/check_dhcp -v -s 192.168.1.129 -r 192.168.1.130
Requested server address: 192.168.1.129
DHCP socket: 3
Hardware address: 08:00:27:b6:c1:90
DHCPDISCOVER to 255.255.255.255 port 67
DHCPDISCOVER XID: 984913524 (0x3AB49674)
DHCDISCOVER ciaddr:  0.0.0.0
DHCDISCOVER yiaddr:  0.0.0.0
DHCDISCOVER siaddr:  0.0.0.0
DHCDISCOVER giaddr:  0.0.0.0
send_dhcp_packet result: 548

recv_result_1: 548
recv_result_2: 548
receive_dhcp_packet() result: 548
receive_dhcp_packet() source: 10.0.2.2
Result=OK
DHCPOFFER from IP address 10.0.2.2 via 10.0.2.2
DHCPOFFER XID: 984913524 (0x3AB49674)
DHCPOFFER chaddr: 080027B6C190
DHCPOFFER ciaddr: 0.0.0.0
DHCPOFFER yiaddr: 10.0.2.15
DHCPOFFER siaddr: 10.0.2.4
DHCPOFFER giaddr: 0.0.0.0
Option: 53 (0x01)
Option: 1 (0x04)
Option: 3 (0x04)
Option: 6 (0x08)
Option: 15 (0x04)
Option: 51 (0x04)
Option: 54 (0x04)
Lease Time: 86400 seconds
Renewal Time: 0 seconds
Rebinding Time: 0 seconds
Added offer from server @ 10.0.2.2 of IP address 10.0.2.15

No (more) data received (nfound: 0)
Result=ERROR
Total responses seen on the wire: 1
Valid responses for this machine: 1
CRITICAL: Received 1 DHCPOFFER(s), 0 of 1 requested servers responded, requested address (192.168.1.130) was not offered, max lease time = 86400 sec.

When attached to br0 with interface=br0 after check_dhcp command I'm not getting even

dnsmasq-dhcp: no address range available for DHCP request via eth0

... in logs. Contrary to when dnsmasq is attached to eth0 Its like my dnsmasq gets ignored and I get response from docker dhcp server.

Last but not least my route -n

0.0.0.0         10.0.2.2        0.0.0.0         UG    0      0        0 eth0
10.0.2.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.1.128   0.0.0.0         255.255.255.128 U     0      0        0 br0
192.168.56.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1

~ thanks for help, greatly appreciated

sebastian_t
  • 111
  • 5

1 Answers1

1

I had solved the same "challenge". At the end I found out, that I didn't have set IP address of my host server. After manual setting IP dnsmasq worked.

ip addr add <IP> dev <NET_INTERFACE>
waldauf
  • 121
  • 3