目录
- 安装
- 配置
- 服务管理
- 测试解析
安装
废话不多述,上来就安装
yum install -y bind-utils dnsmasq
配置
[[email protected] ~]# rpm -ql dnsmasq
/etc/dbus-1/system.d/dnsmasq.conf
/etc/dnsmasq.conf # 主配置文件
/etc/dnsmasq.d
/usr/lib/systemd/system/dnsmasq.service
/usr/sbin/dnsmasq # 命令
/usr/share/doc/dnsmasq-2.76
/usr/share/doc/dnsmasq-2.76/CHANGELOG
/usr/share/doc/dnsmasq-2.76/COPYING
/usr/share/doc/dnsmasq-2.76/COPYING-v3
/usr/share/doc/dnsmasq-2.76/DBus-interface
/usr/share/doc/dnsmasq-2.76/FAQ
/usr/share/doc/dnsmasq-2.76/doc.html
/usr/share/doc/dnsmasq-2.76/setup.html
/usr/share/man/man8/dnsmasq.8.gz
/var/lib/dnsmasq
修改配置如下
[[email protected] ~]# egrep -v '^#|^$' /etc/dnsmasq.conf
port=53
resolv-file=/etc/resolv.conf
strict-order
listen-address=192.168.1.122,127.0.0.1
addn-hosts=/etc/dnsmasq_hosts
cache-size=150
conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig
创建 /etc/dnsmasq_hosts
解析文件,并写入配置
[[email protected] ~]# cat /etc/dnsmasq_hosts
192.168.1.90 vip01 vip01.k8s.com
服务管理
# 启动
systemctl start dnsmasq
# 关闭
systemctl stop dnsmasq
# 开机自启
systemctl enable dnsmasq
测试解析
[[email protected] ~]# dig vip01.k8s.com @192.168.1.122
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> vip01.k8s.com @192.168.1.122
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53340
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 3
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;vip01.k8s.com. IN A
;; ANSWER SECTION:
vip01.k8s.com. 86400 IN A 192.168.1.90
;; AUTHORITY SECTION:
k8s.com. 86400 IN NS k8s.com.
;; ADDITIONAL SECTION:
k8s.com. 86400 IN A 127.0.0.1
k8s.com. 86400 IN AAAA ::1
;; Query time: 0 msec
;; SERVER: 192.168.1.122#53(192.168.1.122)
;; WHEN: Wed Nov 06 22:12:22 CST 2019
;; MSG SIZE rcvd: 116
原文地址:https://www.cnblogs.com/winstom/p/11809066.html
时间: 2024-10-09 00:45:10