CentOS7 上部署 dnsmasq
1、安裝 dnsmasq
yum install -y dnsmasq
2、修改配置
$ grep -v '^#' /etc/dnsmasq.conf |grep -v '^$'
resolv-file=/etc/resolv.dnsmasq.conf
strict-order
server=114.114.114.114
listen-address=172.20.72.7,127.0.0.1
addn-hosts=/etc/dnsmasq.hosts
cache-size=10240 # 緩存條數(shù)
bogus-nxdomain=114.114.114.114
log-queries # 記錄查詢?nèi)罩?log-facility=/var/log/dnsmasq/dnsmasq.log
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
3、創(chuàng)建日志目錄,不然無(wú)法啟動(dòng)
mkdir /var/log/dnsmasq/
4、修改 resolv-file
$ vim /etc/resolv.dnsmasq.conf
nameserver 114.114.114.114
nameserver 1.0.0.1
nameserver 1.1.1.1
5、添加 hosts
$ vim /etc/dnsmasq.hosts
123.206.16.61 www.psy.com
6、啟動(dòng)服務(wù)
systemctl enable dnsmasq --now
7、找一臺(tái)機(jī)器將 dns 指向 dnsmasq 服務(wù)器地址
$ vim /etc/resolv.conf
nameserver 127.0.0.1
$ nslookup
> www.psy.com
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: www.psy.com
Address: 123.206.16.61
> www.baidu.com
Server: 114.114.114.114
Address: 114.114.114.114#53
Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 61.135.169.121
Name: www.a.shifen.com
Address: 61.135.169.125
參考文檔
浙公網(wǎng)安備 33010602011771號(hào)