参考:http://blog.51cto.com/longlei/2065967
1. 安装:
yum install -y dnsmasq
2. 修改/etc/dnsmasq.conf
port=53
listen-address=127.0.0.1,192.168.100.10
#自定义域名
address=/double-click.net/192.168.100.1
address=/fortest.net/192.168.100.2
address=/fortest.com/192.168.100.3
其中192.168.100.10为当前服务器的ip地址
并将/etc/dnsmasq.conf拷贝到/etc/NetworkManager/dnsmasq.d/目录下
注意:
如果降listen-address配置为0.0.0.0,可能会在/var/log/message中看到如下错误:
NetworkManager[15796]: <warn> [1549023135.1725] dnsmasq[0x7f1ca501c500]: dnsmasq exited with error: Network access problem (address in use, permissions) (2)
3. 修改/etc/NetworkManager/NetworkManager.conf
在main下加入dns=dnsmasq
[main]
plugins=ifcfg-rh
dns=dnsmasq
[logging]
#level=DEBUG
#domains=ALL
4. 执行service NetworkManager restart
5. 修改其他服务器的/etc/resolv.conf,将nameserver配置为dns服务器的ip即192.168.100.10。之后执行
ping fortest.net检查返回的ip是否正确
注意,也可以省略3、4步,直接执行service dnsmasq restart,启动dnsmasq服务。但是dnsmasq单独启动方式,打印的日志太简单,省略了一些报错信息。