dnsmasq

docker: https://hub.docker.com/r/jpillora/dnsmasq/

  1. vim /opt/dnsmasq.conf
  2. #dnsmasq config, for a complete example, see:
  3. # http://oss.segetech.com/intra/srv/dnsmasq.conf
  4. #log all dns queries
  5. log-queries
  6. #dont use hosts nameservers
  7. no-resolv
  8. #use google as default nameservers
  9. server=8.8.4.4
  10. server=8.8.8.8
  11. #serve all .company queries using a specific nameserver
  12. server=/company/10.0.0.1
  13. #explicitly define host-ip mappings
  14. address=/myhost.company/10.0.0.2
  15. docker run --name dnsmasq -d -p 53:53/udp -p 5380:8080 -v /opt/dnsmasq.conf:/etc/dnsmasq.conf \
  16. -e "HTTP_USER=ushare" -e "HTTP_PASS=usharednsmasq" --restart always jpillora/dnsmasq

BlackholeJ

简介

基于Java的dns服务器, 配置简单, 即插即用.
http://code4craft.github.io/blackhole/

安装

  1. curl http://code4craft.github.io/blackhole/install.sh | sh

配置

前置操作:

  • 关防火墙

  • 关selinux

  • 关bind9

逐个添加想要配置的域名和对应的ip即可, 支持通配符

  1. sudo vim /usr/local/blackhole/config/zones

运行/停止

  1. sudo /usr/local/blackhole/blackhole.sh start|stop

自动启动

添加service配置

  1. sudo vim /lib/systemd/system/blackhole.service # Ubuntu
  2. sudo vim /usr/lib/systemd/system/blackhole.service # Centos

输入配置如下:

  1. [Unit]
  2. Description=BlackHoleJ Domain Name Server
  3. Documentation=man:named(8)
  4. After=network.target
  5. [Service]
  6. ExecStart=/usr/local/blackhole/blackhole.sh start
  7. ExecReload=/usr/local/blackhole/blackhole.sh reload
  8. ExecStop=/usr/local/blackhole/blackhole.sh stop
  9. Type=forking
  10. KillMode=process
  11. Restart=on-failure
  12. RestartSec=42s
  13. [Install]
  14. WantedBy=multi-user.target

然后执行

  1. sudo systemctl enable blackhole.service
  2. sudo systemctl start blackhole.service