配置
修改区域配置文件
$ vim /etc/named.rfc1912.zones
zone "hxg.com" IN { #添加域名对应的数据库文件
type master;
file "hxg.com.zone";
};
新建数据库文件
$ touch /var/named/hxg.com.zone
$ chgrp named /var/named/hxg.com.zone #修改所属组
$ chmod o= /var/named/hxg.com.zone #去掉other的权限
# 或者直接复制原本的数据库文件
$ cp -p /var/named/named.localhost /var/named/hxg.com.zone
$ vim /var/named/hxg.com.zone #编写数据库文件
$TTL 1D
@ IN SOA master admin ( 50 2H 10M 1W 1D )
NS master
master A 192.168.3.102
web A 192.168.3.101
www CNAME web
* CNAME web
@ A 192.168.3.101
app A 1.1.1.1
db A 2.2.2.2
检查配置文件是否正常
named-checkconf
检查区域数据库的语法
格式:named-checkzone 域名 域名对应的数据库文件
named-checkzone hxg.com /var/named/hxg.com.zone
重新加载数据
rndc reload
测试
客户端上安装bind-utils
yum -y install bind-utils
安装apache
yum -y install httpd
写入主页文件
echo "192.168.3.101 ------>/var/www/html/index.html" > /var/www/html/index.html
开启服务
systemctl start httpd
修改DNS
vim /etc/sysconfig/network-scripts/ifcfg-ens32
加载dns设置
nmcli connection reload
nmcli connection up ens32
#连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/2)
测试
dig www.hxg.com
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-16.P2.el7 <<>> www.hxg.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21115
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 2
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.hxg.com. IN A
;; ANSWER SECTION:
www.hxg.com. 86400 IN CNAME web.hxg.com.
web.hxg.com. 86400 IN A 192.168.3.101
;; AUTHORITY SECTION:
hxg.com. 86400 IN NS master.hxg.com.
;; ADDITIONAL SECTION:
master.hxg.com. 86400 IN A 192.168.3.102
;; Query time: 0 msec
;; SERVER: 192.168.3.102#53(192.168.3.102)
;; WHEN: 一 6月 08 06:15:02 CST 2020
;; MSG SIZE rcvd: 110
已经解析成功
标签:named,hxg,zone,www,DNS,var,服务器,解析,com From: https://www.cnblogs.com/guangdelw/p/17300877.html