debian部署dns服务器
安装及验证
安装
sudo apt update
sudo apt install dnsmasq
在配置文件中添加如下内容:
nano /etc/dnsmasq.conf
server=114.114.114.114
server=8.8.8.8
addn-hosts=/etc/hosts
service dnsmasq restart
验证,使用其他主机向该dns服务器发起询问
nslookup www.baidu.com 192.168.88.148(dns的ip)
正向地址解析:
修改/etc/hosts文件
添加:127.0.0.1 www.chmod.com
重启dnsmasq服务
service dnsmasq restart
验证
nslookup www.chmod.com(自定义的域名) 192.168.88.148(dns的ip)
泛域名解析
实现123.123.123.123 *.chmod666.top
在配置文件中:/etc/dnsmasq.conf添加如下内容
address=/chmod666.top/123.123.123.123
service dnsmasq restart
允许其他网段查询dns(默认仅允许同网段)
interface=ens33
参考
`dnsmasq` can be configured to only accept queries from at-most-one-hop-away addresses using the option `local-service`. Other queries are discarded in this case.
This is meant to be a safe default to keep otherwise unconfigured installations safe. Note that `local-service` is ignored if *any* access-control config is in place (`interface`, `except-interface`, `listen-address` or `auth-server`).