RHCE-4-搭建DNS服务器

搭建主DNS服务器,要求如下:该DNS服务器能解析www.qq.com和www.163.com的IP地址

安装dns服务

[root@server ~]# yum install bind -y

修改/etc/named.conf配置文件

[root@server named]# vim /etc/named.conf
[root@server named]# cat /etc/named.conf
options {
	listen-on port 53 { 192.168.21.128; };
	directory 	"/var/named";
};

zone "qq.com" IN {
	type master;
	file "named.qq.com";
};

zone "163.com" IN {
        type master;
        file "named.163.com";
};

创建/var/named/named.qq.com

[root@server named]# vim /var/named/named.qq.com 
[root@server named]# cat /var/named/named.qq.com 
$TTL 1D
@	IN SOA	master.qq.com. admin.qq.com. (
					1942	; serial
					1D	; refresh
					1H	; retry
					1W	; expire
					3H )	; minimum
	IN NS	master.qq.com.
master	IN A	192.168.21.128		
www	IN A	192.168.21.1
wwww	IN CNAME www

创建/var/named/named.163.com

[root@server named]# vim /var/named/named.163.com 
[root@server named]# cat /var/named/named.163.com 
$TTL 1D
@	IN SOA	master.163.com. admin.163.com. (
					1942	; serial
					1D	; refresh
					1H	; retry
					1W	; expire
					3H )	; minimum
	IN NS	master.163.com.
master	IN A	192.168.21.128		
www	IN A	192.168.21.3
wwww	IN CNAME www

验证解析

[root@server named]# dig @192.168.21.128 www.qq.com

; <<>> DiG 9.11.26-RedHat-9.11.26-6.el8 <<>> @192.168.21.128 www.qq.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 9043
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: ce63a594619a9ddefbdd18b46377af356869e8236ce96dfb (good)
;; QUESTION SECTION:
;www.qq.com.			IN	A

;; ANSWER SECTION:
www.qq.com.		86400	IN	A	192.168.21.1

;; AUTHORITY SECTION:
qq.com.			86400	IN	NS	master.qq.com.

;; ADDITIONAL SECTION:
master.qq.com.		86400	IN	A	192.168.21.128

;; Query time: 0 msec
;; SERVER: 192.168.21.128#53(192.168.21.128)
;; WHEN: Sat Nov 19 00:13:41 CST 2022
;; MSG SIZE  rcvd: 120

[root@server named]# dig @192.168.21.128 www.163.com

; <<>> DiG 9.11.26-RedHat-9.11.26-6.el8 <<>> @192.168.21.128 www.163.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15868
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: b2cf5592402bb674be7b883e6377af3b9600f82eeef02b1a (good)
;; QUESTION SECTION:
;www.163.com.			IN	A

;; ANSWER SECTION:
www.163.com.		86400	IN	A	192.168.21.3

;; AUTHORITY SECTION:
163.com.		86400	IN	NS	master.163.com.

;; ADDITIONAL SECTION:
master.163.com.		86400	IN	A	192.168.21.128

;; Query time: 0 msec
;; SERVER: 192.168.21.128#53(192.168.21.128)
;; WHEN: Sat Nov 19 00:13:47 CST 2022
;; MSG SIZE  rcvd: 121

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值