新聞中心
DNSmasq是一個小巧且方便地用于配置DNS和DHCP的工具,適用于小型網(wǎng)絡,它提供了DNS功能和可選擇的DHCP功能。它服務那些只在本地適用的域名,這些域名是不會在全球的DNS服務器中出現(xiàn)的,下面為大家詳細講解一下Linux下使用DNSmasq建本地DNS服務器具體方法。

創(chuàng)新互聯(lián)專注于珠海網(wǎng)站建設服務及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供珠海營銷型網(wǎng)站建設,珠海網(wǎng)站制作、珠海網(wǎng)頁設計、珠海網(wǎng)站官網(wǎng)定制、小程序制作服務,打造珠海網(wǎng)絡公司原創(chuàng)品牌,更為您提供珠海網(wǎng)站排名全網(wǎng)營銷落地服務。
一、Dnsmasq安裝
安裝并啟動Dnsmasq
yum install -y dnsmasq
service dnsmasq start
二、Dnsmasq配置
1、Dnsmasq的配置文件路徑為:/etc/dnsmasq.conf
# ll -d /etc/dnsmasq.conf
-rw-r--r-- 1 root root 21237 Feb 23 00:17 /etc/dnsmasq.conf
2、編輯/etc/dnsmasq.conf
resolv-file=/etc/resolv.dnsmasq.conf //dnsmasq 會從這個文件中尋找上游dns服務器
strict-order //去掉前面的#
addn-hosts=/etc/dnsmasq.hosts //在這個目里面添加記錄
listen-address=127.0.0.1,192.168.1.123 //監(jiān)聽地址
3、修改/etc/resolv.conf
echo 'nameserver 127.0.0.1' > /etc/resolv.conf
4、創(chuàng)建resolv.dnsmasq.conf文件并添加上游dns服務器的地址
touch /etc/resolv.dnsmasq.conf
echo 'nameserver 119.29.29.29' > /etc/resolv.dnsmasq.conf
5、創(chuàng)建dnsmasq.hosts文件
cp /etc/hosts /etc/dnsmasq.hosts
echo 'addn-hosts=/etc/dnsmasq.hosts' >> /etc/dnsmasq.conf
提示:resolv.dnsmasq.conf中設置的是真正的Nameserver,可以用電信、聯(lián)通等公共的DNS。
三、Dnsmasq啟動
1、設置Dnsmasq開機啟動并啟動Dnsmasq服務:
chkconfig dnsmasq on
/etc/init.d/dnsmasq restart
2、netstat -tunlp|grep 53 查看Dnsmasq是否正常啟動:
# netstat -tlunp|grep 53
tcp 0 0 0.0.0.0:53 0.0.0.0:* LISTEN 2491/dnsmasq
tcp 0 0 :::53 :::* LISTEN 2491/dnsmasq
udp 0 0 0.0.0.0:53 0.0.0.0:* 2491/dnsmasq
udp 0 0 :::53 :::* 2491/dnsmasq
3、dig www.freehao123.com,第一次是沒有緩存,所以時間是200多
使用Dnsmasq搭建本地dns服務器上網(wǎng)使用Dnsmasq搭建本地dns服務器上網(wǎng)
4、第二次再次測試,因為已經(jīng)有了緩存,所以查詢時間已經(jīng)變成了0.
使用Dnsmasq搭建本地dns服務器上網(wǎng)使用Dnsmasq搭建本地dns服務器上網(wǎng)
網(wǎng)頁標題:Linux下使用DNSmasq建本地DNS服務器
本文地址:http://fisionsoft.com.cn/article/dppigjj.html


咨詢
建站咨詢
