安装Dnsmasq
[root@vdevops ~]# yum -y install dnsmasq [root@vdevops ~]# vi /etc/dnsmasq.conf # line 19: 取消注释(从不转发普通名称) domain-needed # line 21: 取消注释 (从不转发非路由地址空间中的地址) bogus-priv # line 41: 取消注释 (查询每个服务器严格按照resolv.conf中的顺序) strict-order # line 55: 添加下面一行 (查询特定域名到特定的DNS服务器) server=/linuxprobe.org/10.1.1.53 # line 123: 取消注释 (自动添加域名) expand-hosts # line 133: 添加 (定义域名) domain=srv.world [root@vdevops ~]# systemctl start dnsmasq [root@vdevops ~]# systemctl enable dnsmasq 对于DNS记录,将它们添加到/etc/hosts中,然后,Dnsmasq将回答客户端的查询。 [root@vdevops ~]# cat vim /etc/hosts cat: vim: No such file or directory 127.0.0.1 localhost localhost.localdomain vdevops.com 10.1.1.53 linuxprobe.org # add records 10.1.1.56 vdevops.com vdevops [root@vdevops ~]# systemctl restart dnsmasq 如果防火墙是开启的,需要做下面设置 [root@vdevops ~]# systemctl start firewalld [root@vdevops ~]# firewall-cmd --add-service=dns --permanent success [root@vdevops ~]# firewall-cmd --reload success 验证以从内部网络中的客户端解析名称或IP地址,在其他服务器上面操作 [root@linuxprobe ~]# yum -y install bind-utils 将DNS设置更改为Dnsmasq Server(将“eno16777736 ”替换为您自己的环境,即更改接口的DNS) [root@linuxprobe ~]# nmcli c modify eno16777736 ipv4.dns 10.1.1.56 [root@linuxprobe ~]# nmcli c down eno16777736; nmcli c up eno16777736 [root@linuxprobe ~]# dig vdevops.org ; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.4 <<>> vdevops.org ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30866 ;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; WARNING: recursion requested but not available ;; QUESTION SECTION: ;vdevops.org. IN A ;; ANSWER SECTION: vdevops.org. 128 IN A 180.168.41.175 ;; Query time: 46 msec ;; SERVER: 10.1.1.1#53(10.1.1.1) ;; WHEN: Thu Oct 27 18:07:23 CST 2016 ;; MSG SIZE rcvd: 45 [root@linuxprobe ~]# dig -x 10.1.1.56 ; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.4 <<>> -x 10.1.1.56 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13696 ;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;56.1.1.10.in-addr.arpa. IN PTR ;; ANSWER SECTION: 56.1.1.10.in-addr.arpa. 0 IN PTR vdevops.org. ;; Query time: 2 msec ;; SERVER: 10.1.1.56#53(10.1.1.56) ;; WHEN: Thu Oct 27 18:07:51 CST 2016 ;; MSG SIZE rcvd: 65 #### Dnsmasq:配置DHCP服务器## 在Dnsmasq中启用集成DHCP功能并配置DHCP服务器 [root@vdevops ~]# vi /etc/dnsmasq.conf
Oct 27 18:14:55 vdevops.org systemd[1]: Started DNS caching server.. Oct 27 18:14:55 vdevops.org systemd[1]: Starting DNS caching server…. Oct 27 18:14:55 vdevops.org dnsmasq[7786]: started, version 2.66 cachesize 150 Oct 27 18:14:55 vdevops.org dnsmasq[7786]: compile time options: IPv6 GNU-getopt DBus no-i18n IDN DHCP DHCPv6 no-Lua TFTP no-conntrac…et auth Oct 27 18:14:55 vdevops.org dnsmasq-dhcp[7786]: DHCP, IP range 10.1.1.10 – 10.1.1.30, lease time 12h Oct 27 18:14:55 vdevops.org dnsmasq[7786]: using nameserver 10.1.1.53#53 for domain linuxprobe.org Oct 27 18:14:55 vdevops.org dnsmasq[7786]: reading /etc/resolv.conf Oct 27 18:14:55 vdevops.org dnsmasq[7786]: using nameserver 10.1.1.1#53 Oct 27 18:14:55 vdevops.org dnsmasq[7786]: using nameserver 10.1.1.53#53 for domain linuxprobe.org Oct 27 18:14:55 vdevops.org dnsmasq[7786]: read /etc/hosts - 3 addresses Hint: Some lines were ellipsized, use -l to show in full. “` |