时间:2020-07-05来源:www.pcxitongcheng.com作者:电脑系统城
1 安装
yum -y install dnsmasq
开放udp tcp 53 端口
2,修改配置文件 dnsmasq.conf
# grep -Ev "^$|^[#;]" /etc/dnsmasq.conf 查看文件中未注释的内容信息
# vi /etc/dnsmasq.conf
1 2 3 4 5 6 7 8 |
#指定上游dns服务器 resolv-file=/etc/resolv.dnsmasq.conf #表示严格按照 resolv-file 文件中的顺序从上到下进行 DNS 解析, 直到第一个成功解析成功为止 strict-order # 开启后会寻找本地的hosts文件在去寻找缓存的域名,最后到上游dns查找 #no-resolv listen-address= 192.168 . 90.224 , 127.0 . 0.1 # 0.0 . 0.0 设置为公网IP conf-dir=/etc/dnsmasq.d # 我们的解析记录都写到这个目录下 |
3, 新建resolv.dnsmasq.conf ,这个文件用来设置上游DNS地址,按照顺序依次轮询
vi/etc/resolv.dnsmasq.conf
1 2 3 4 5 |
nameserver 114.114 . 114.114 nameserver 8.8 . 8.8 nameserver 168.95 . 1.1 nameserver 202.101 . 172.35 nameserver 202.101 . 172.47 |
4,新建域名解析配置文件
新建文件 /etc/dnsmasq.d/address.conf
1 2 3 4 5 |
address=/uac.test. 3028 .com/ 192.168 . 90.220 #正向解析 address=/www.taobao.com/ 127.0 . 0.1 #正向解析 ptr-record= 127.0 . 0.1 .in-addr.arpa,www.taobao.com #反向解析(可选) address=/baidu.com/ 127.0 . 0.1 #泛域名解析 |
5 开机启动,日志查看
1 2 3 |
systemctl enable dnsmasq systemctl start dnsmasq systemctl restart dnsmasq |
1 2 3 |
#查看dnsmasq是否启动正常,查看系统日志: journalctl -u dnsmasq /var/log/dnsmasq.log |
6 dns 测试
linux下提供nslookup命令的软件就是 bind-utils
1 2 |
yum install bind-utils -y nslookup uac.test. 3028 .com |
安装dig yum install bind-utils
测试dns缓存,要测试查询速度,请访问一个 dnsmasq 启动后没有访问过的网站,执行
1 2 3 4 |
[root @node ~]# dig uac.test. 3028 .com | grep "Query time" ;; Query time: 212 msec [root @node ~]# dig uac.test. 3028 .com | grep "Query time" ;; Query time: 2 msec |
再次运行命令,因为使用了缓存,查询时间应该大大缩短。
2023-02-28
解决linux不识别nfst格式u盘问题技巧 linux无法识别ntfs格式U盘怎么办?2023-02-28
linux扩容swap分区的技巧 linux怎么调整swap大小?2023-02-26
微软Linux资源库首次加入Edge浏览器稳定版当linux在运作时不能直接关闭电源容易将档案系统损毁,因此需要用shutdown以安全的方式关闭,那么这个操作该怎么实现呢?下面就为大家带来了详细教程。...
2022-11-07
由于linux系统和我们常用的windows系统是不一样的,所以如果是初学者,可能会不知道linux怎么强制删除文件,其实我们只要打开终端,使用命令就可以删除了。...
2022-11-03