CentOS7使用DNSmasq搭建DNS服务器
DNSmasq是一个小巧且方便地用于配置DNS和DHCP的工具,适用于小型网络,它提供了DNS功能和可选择的DHCP功能。服务那些只在本地适用的域名,这些域名是不会在全球的DNS服务器中出现的,DNSmasq支持静态和动态两种DHCP配置方式
安装
yum install -y dnsmasq rpm -ql dnsmasq
配置
vim /etc/dnsmasq.conf #清空内容后添加 resolv-file=/etc/resolv.dnsmasq.conf #指定上游服务器 strict-order #严格按照resolv.conf中的顺序进行查找 listen-address=172.16.2.111,127.0.0.1 #监听地址 addn-hosts=/etc/dnsmasq.hosts #自建解析 cache-size=150 conf-dir=/etc/dnsmasq.d #检查配置 egrep -v '^#|^$' /etc/dnsmasq.conf
指定上游DNS
vim /etc/resolv.dnsmasq.conf #添加 nameserver 8.8.8.8 nameserver 114.114.114.114
自建解析
vim /etc/dnsmasq.hosts #添加 172.16.2.121 vsan1.vos.local 172.16.2.122 vsan2.vos.local 172.16.2.123 vsan3.vos.local 172.16.2.124 vc.vos.local
设置自启
systemctl enable dnsmasq killall dnsmasq systemctl start dnsmasq systemctl status dnsmasq
测试
yum install bind-utils -y dig vsan3.vos.local @127.0.0.1 nslookup vc.vos.local
本站所有文章均可随意转载,转载时请保留原文链接及作者。