dnsmasq
buyfakett
dnsmasq
dns
和dhcp
的轻量服务端
启动
#!/bin/bash
#############
# dnsmasq
###########
docker stop dnsmasq
docker rm dnsmasq
docker run -d \
--restart=always \
--net host \
--name dnsmasq \
--privileged \
-e TZ=Asia/Shanghai \
-e HTTP_USER=muen \
-e HTTP_PASS=ePDWG22CKmnD2Waa \
-e PORT=5380 \
-v $(pwd)/config/dnsmasq.conf:/etc/dnsmasq.conf:rw \
-v $(pwd)/dhcp-hosts.d/:/etc/dnsmasq/dhcp-hosts.d/ \
jpillora/dnsmasq:1.1.0
配置
# dnsmasq config, for a complete example, see:
# http://oss.segetech.com/intra/srv/dnsmasq.conf
# 配置文档
# https://e-mailky.github.io/2018-07-14-dnsmasq
# log all dns queries
log-queries
# dont use hosts nameservers
no-resolv
# use cloudflare as default nameservers, prefer 1^4
server=223.5.5.5
server=8.8.8.8
strict-order
# serve all .company queries using a specific nameserver
server=/company/10.0.0.1
# explicitly define host-ip mappings
address=/myhost.company/10.0.0.2
# 国内指定DNS
# server=/cn/114.114.114.114
# server=/taobao.com/114.114.114.114
# server=/taobaocdn.com/114.114.114.114
# 国外指定DNS
# server=/google.com/223.5.5.5
######################## dhcp ####################################
# dhcp逻辑文件, 修改会自动重载
dhcp-hostsdir=/etc/dnsmasq/dhcp-hosts.d
# Dynamic range of IPs to make available to LAN pc
dhcp-range=10.32.9.2,10.32.9.254,255.255.240.0,12h
# If you’d like to have dnsmasq assign static IPs, bind the LAN computer's
# NIC MAC address:
dhcp-host=aa:bb:cc:dd:ee:ff,192.168.111.50
TIP
由于配置中配置了dhcp-hostsdir
, dhcp
的配置可以放在/etc/dnsmasq/dhcp-hosts.d
, 服务会自动重载
00:66:77:88:99:AA,192.168.1.101
00:66:77:88:99:AA,host2,192.168.1.101,24h