[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/hostscat: vim: No such file or directory127.0.0.1 localhost localhost.localdomain vdevops.com 10.1.1.53 linuxprobe.org# add records10.1.1.56 vdevops.com vdevops[root@vdevops ~]# systemctl restart dnsmasq
如果防火牆是開啟的,需要做下面設置
[root@vdevops ~]# systemctl start firewalld[root@vdevops ~]# firewall-cmd --add-service=dns --permanentsuccess[root@vdevops ~]# firewall-cmd --reloadsuccess
驗證以從內部網絡中的客戶端解析名稱或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. “`
參考鏈接:https://wiki.archlinux.org/index.php/Dnsmasq_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)#.E5.AE.89.E8.A3.85
http://xxxxxx/Linuxjc/1184686.html TechArticle