1. 安装dnsmasq 

apt install dnsmasq

2. 删除 systemd-resolved

 apt remove systemd-resolved

3. 配置dnsmasq

#开启外网服务,不然只能给内网使用,这两个要同时开启才有效,不知道为什么
listen-address=0.0.0.0
bind-interfaces

#不提供dhcp服务
no-dhcp-interface=

#不读取/etc/resolv.conf的配置
no-resolv
#自定义上游dns服务器地址
server=223.5.5.5
server=223.6.6.6

#可自定义某个域名的解析服务器
server=/domain/x.x.x.x

4. 启动dnsmasq

systemctl start dnsmasq

5. 测试

dig @127.0.0.1 baidu.com

 

标签: none