- dnsmasq简介
- dnsmasq安装
1
2
3
4
5
6
7
8sudo yum install dnsmasq dnsmasq-utils # 安装dnsmasq包(CentOS)
sudo cp /etc/dnsmasq.conf /etc/dnsmasq.conf.backup.20190719 # 备份配置文件
sudo systemctl enable dnsmasq # 设置开机启动
sudo systemctl start dnsmasq # 启动dnsmasq
sudo systemctl status dnsmasq # 查看dnsmasq状态
sudo firewall-cmd --zone=public --add-port=53/tcp # 配置防火墙
sudo firewall-cmd --zone=public --add-port=53/udp
sudo firewall-cmd --runtime-to-permanent # 保存防火墙配置1
2
3sudo apt-get install dnsmasq # 安装dnsmasq包(Ubuntu)
sudo cp /etc/dnsmasq.conf /etc/dnsmasq.conf.backup.20190719 # 备份配置文件
... - 配置dnsmasq服务
1
sudo vi /etc/dnsmasq.conf # 编辑dnsmasq配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27domain-needed
bogus-priv
no-resolv # 不读取本地dns配置,如/etc/resolv.conf
no-poll
server=8.8.8.8 # 上游DNS服务
server=1.1.1.1
server=223.5.5.5
server=223.6.6.6
server=114.114.114.114
local=/localnet/ # 从/etc/hosts解析域名
address=/test.zhangpp.net/127.0.0.1 # 自定义域名-IP列表
address=/test2.zhangpp.net/192.168.1.2
listen-address=127.0.0.1 # 端口监听地址
listen-address=192.168.x.x
bind-interfaces
expand-hosts
log-queries # 开启日志
log-facility=/var/log/dnsmasq.log # 日志文件
conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig1
2sudo systemctl restart dnsmasq # 重启dnsmasq
sudo systemctl status dnsmasq # 查看dnsmasq状态 - 使用dnsmasq
- 配置电脑,自定义DNS
- 或者将自己搭建的DNS配置到路由器,这样就不需要配置电脑/手机了