1、安装

dnf -y install dnsmasq

2、配置文件修改

# vim /etc/dnsmasq.conf
...
resolv-file=/etc/resolv.dnsmasq.conf
strict-order
user=dnsmasq
group=dnsmasq
listen-address=172.16.24.111,127.0.0.1
no-hosts
addn-hosts=/etc/dnsmasq.hosts
cache-size=300
conf-dir=/etc/dnsmasq.d
dns-forward-max=1024
...

# vim /etc/resolv.dnsmasq.conf
nameserver 223.5.5.5
nameserver 119.29.29.29
nameserver 1.2.4.8

# vim /etc/dnsmasq.hosts
172.16.24.118    www.istack.com
172.16.24.172    wiki.istack.com

# vim /etc/dnsmasq.d/address.conf
all-servers
server=119.29.29.29
server=223.5.5.5
server=1.2.4.8
bogus-nxdomain=119.29.29.29

address=/www.istack.com/127.0.0.1
address=/wiki.istack.com/127.0.0.1

# vim /etc/resolv.conf 
...
nameserver 127.0.0.1

3、配置文件语法检查

dnsmasq --test

4、启动服务

systemctl enable --now dnsmasq

5、国内外域名分流解析

参考:https://github.com/felixonmars/dnsmasq-china-list

  

posted on 2023-04-20 09:05  a120608yby  阅读(148)  评论(0编辑  收藏  举报