1编译安装
wget https://thekelleys.org.uk/dnsmasq/dnsmasq-2.90.tar.gz
#解压
tar zxvf dnsmasq-2.90.tar.gz
#
cd dnsmasq-2.90/
make
make install
#查看版本
dnsmasq -v
2 配置
mkdir -p /etc/dnsmasq.d/
vim /etc/dnsmasq.conf
#启动端口
port=53
#不解析/etc/hosts文件
no-hosts
#解析域名记录
addn-hosts=/etc/dnsmasq.d/dnsmasq.hosts
#上游dns
resolv-file=/etc/dnsmasq.d/resolv.dnsmasq.conf
#禁用轮询机制
no-poll
#按照顺序解析
strict-order
#记录dns查询日志
log-queries
#设置日志文件
log-facility=/var/log/dnsmasq.log
#本地缓存时间,根据实际情况配置
local-ttl=86500
#缓存数量
cache-size=1000
#监听地址
listen-address=192.168.50.18,127.0.0.1
#增加解析记录
sudo vim /etc/dnsmasq.d/dnsmasq.hosts
192.168.50.18 www.test.com
#设置上游DNS地址
sudo vim /etc/dnsmasq.d/resolv.dnsmasq.conf
nameserver 223.6.6.6
nameserver 114.114.114.114
3 启动
#语法检查
dnsmasq --test
dnsmasq: syntax check OK.
#启动
dnsmasq
#查看端口
netstat -atlp| grep dnsmasq