實驗環境
搭建一個内網的dns伺服器,實作通路内網的網站

DNS 伺服器
安裝
yum install bind bind-utils -y
配置檔案
vim /etc/named.conf
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
vim /etc/named.rfc1912.zones
zone "xuepeng.com" IN {
type master;
file "xuepeng.com.zone";
};
區域資料庫檔案
vim /var/named/xuepeng.com.zone
$TTL 1D
@ IN SOA master admin ( 20200222 8H 30m 5D 9H )
NS master
master A 192.168.43.7
websrv A 192.168.43.17
www CNAME websrv
檢測文法
named-checkconf
named-checkzone xuepeng.com xuepeng.com.zone
開啟服務
systemctl start named
DNS 用戶端
grep DNS /etc/sysconfig/network-scripts/ifcfg-eth0
DNS1=192.168.43.7
websrv 伺服器
yum install httpd -y
echo www.xuepeng.com > /var/www/html/index.html
systemctl enable --now httpd
測試
允許動态更新
允許遠端的一台機器能夠更新dns伺服器的區域資料庫檔案
區域資料庫檔案配置
vim /etc/named.rfc1912.zones
zone "xuepeng.com" IN {
type master;
file "xuepeng.com.zone";
allow-update { 192.168.43.16; }; //允許192.168.43.16更新區域資料庫檔案
};
selinux配置
chmod 770 /var/named
setseboot -P named_write_master_zones on
遠端操作
192.168.43.16
[[email protected] ~]# nsupdate
> server 192.168.43.7
> zone xuepeng.com
> update add web.xuepeng.com 9999 IN A 9.9.9.9
> send
> update delete www.xuepeng.com CNAME
> send
> quit
會在 dns伺服器的 /vat/named/目錄下生成一個檔案
注意
- 在區域資料庫檔案中,一個域名對應多個ip,實作基于dns的負載均衡
- 在區域資料庫檔案中,實作泛域名解析
主dns伺服器實作正向解析和動态更新實驗環境DNS 伺服器DNS 用戶端websrv 伺服器測試允許動态更新