dnsmasq 本地局域网DNS服务器搭建

发布时间 2023-07-25 16:37:53作者: 宁采臣open

项目背景

因为本地环境需要使用域名进行调试,需要DNS服务器
DNS 机器IP:192.168.5.249
 

dnsmasq 服务端部署

#01 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
firewall-cmd --state
 
#02 下载服务 dnsmasq
yum install -y dnsmasq
 
#03 修改配置文件
[root@damahou ~]# egrep -v "^#|^$" /etc/dnsmasq.conf
resolv-file=/etc/resolv.dnsmasq.conf
address=/test.com/192.168.5.245
listen-address=192.168.5.249
addn-hosts=/etc/dnsmasq.hosts
log-queries
conf-dir=/etc/dnsmasq.d
conf-dir=/etc/dnsmasq.d,.bak
conf-dir=/etc/dnsmasq.d/,*.conf
conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig
 
 
#04 启动服务
systemctl start dnsmasq
systemctl enable dnsmasq
 
#04 添加需要解析的内网域名
[root@centos7 ~]# cat /etc/dnsmasq.hosts
192.168.5.245 yunyi.com 80
192.168.5.245 zw.yunyi.com 80
192.168.5.245 zf.yunyi.com 80
192.168.5.245 kq.yunyi.com 80
192.168.5.245 dw.yunyi.com 80
 
#05 重启服务生效
systemctl restart dnsmasq.service

使用教程

需要添加DNS 服务器IP:192.168.5.249
 
终端:ping yunyi.com (测试域名) 看是否为DNS解析地址