dnsmasq 本地局域网DNS服务器搭建
项目背景
因为本地环境需要使用域名进行调试,需要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解析地址
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)