VirtualboxDebianマシンでdnsmasqDHCPの構成をテストしています。本番環境では、dnsmasqがqemu + libvirt + openvswitchを介して実行されているゲストシステムに静的IPアドレスを提供するようにします(私がカバーしたものは、dockerを介して実行されており、機能します)
dnsmasq構成:
# 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 [email protected]
# 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"]
コンテナをビルドして実行するコマンド:
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ログ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コマンド(monitoring-plugins-basicパッケージから)
/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.
Check_dhcpコマンドの後にbr with interface = br0に接続すると、均等になりません
dnsmasq-dhcp: no address range available for DHCP request via eth0
...ログに。 dnsmasqがeth0に接続されている場合とは異なり、dnsmasqが無視され、dockerdhcpサーバーから応答が返されます。
最後になりましたが、私の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
〜助けてくれてありがとう、大いに感謝します
私は同じ「挑戦」を解決しました。最後に、ホストサーバーのIPアドレスを設定していないことがわかりました。手動設定後、IPdnsmasqが機能しました。
ip addr add <IP> dev <NET_INTERFACE>