dnsmasq
docker: https://hub.docker.com/r/jpillora/dnsmasq/
vim /opt/dnsmasq.conf
#dnsmasq config, for a complete example, see:
# http://oss.segetech.com/intra/srv/dnsmasq.conf
#log all dns queries
log-queries
#dont use hosts nameservers
no-resolv
#use google as default nameservers
server=8.8.4.4
server=8.8.8.8
#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
docker run --name dnsmasq -d -p 53:53/udp -p 5380:8080 -v /opt/dnsmasq.conf:/etc/dnsmasq.conf \
-e "HTTP_USER=ushare" -e "HTTP_PASS=usharednsmasq" --restart always jpillora/dnsmasq
BlackholeJ
简介
基于Java的dns服务器, 配置简单, 即插即用.
http://code4craft.github.io/blackhole/
安装
curl http://code4craft.github.io/blackhole/install.sh | sh
配置
前置操作:
关防火墙
关selinux
关bind9
逐个添加想要配置的域名和对应的ip即可, 支持通配符
sudo vim /usr/local/blackhole/config/zones
运行/停止
sudo /usr/local/blackhole/blackhole.sh start|stop
自动启动
添加service配置
sudo vim /lib/systemd/system/blackhole.service # Ubuntu
sudo vim /usr/lib/systemd/system/blackhole.service # Centos
输入配置如下:
[Unit]
Description=BlackHoleJ Domain Name Server
Documentation=man:named(8)
After=network.target
[Service]
ExecStart=/usr/local/blackhole/blackhole.sh start
ExecReload=/usr/local/blackhole/blackhole.sh reload
ExecStop=/usr/local/blackhole/blackhole.sh stop
Type=forking
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
然后执行
sudo systemctl enable blackhole.service
sudo systemctl start blackhole.service