从查询内容分类
[root@v1 nginx]# yum -y install bind*
[root@v1 ~]# vim /etc/named.conf
options {
directory "/var/named"; 地址库默认存放位置
};
zone "ys.com" IN { 指定本机服务负责解析的域名
type master; 指定本机为权威DNS服务器
file "ys.com.zone"; 指定地址库文件名称
};
[root@v1 named]# named-checkconf /etc/named.conf
没有提示什么就说明没有问题
[root@v1 ~]# cd /var/named/
[root@v1 named]# cp -p named.localhost ys.com.zone 参考范本建地址库文件
[root@v1 named]# vim ys.com.zone
NS 域名服务器(Name Server)记录
A 地址(Address)记录,仅用于正向解析区域
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS v1 //ys.com这个域名有v1.ys.com这台服务器负责
v1 A 192.168.2.10 //v1.ys.com这台服务器的IP地址时192.168.2.10
www A 8.8.8.8 //www.ys.com的IP地址为8.8.8.8
[root@v1 named]# named-checkzone ys.com ys.com.zone
zone ys.com/IN: loaded serial 0
OK
[root@v1 named]# systemctl start named
[root@v1 named]# systemctl enable named
Created symlink from /etc/systemd/system/multi-user.target.wants/named.service to /usr/lib/systemd/system/named.service.
[root@bogon ~]# vim /etc/resolv.conf 设置192.168.2.20的DNS服务器为192.168.2.10
# Generated by NetworkManager
nameserver 192.168.2.10
[root@bogon ~]# nslookup www.ys.com 解析www.ys.com域名对应的IP地址
Server: 192.168.2.10
Address: 192.168.2.10#53
Name: www.ys.com
Address: 8.8.8.8
注意:这里nslookup命令没有的话需要安装bind-utils这个软件
[root@v1 named]# vim ys.com.zone
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS v1
v1 A 192.168.2.10
www A 192.168.2.100
www A 192.168.2.101
www A 192.168.2.102
www A 192.168.2.103
[root@v1 named]# named-checkzone ys.com ys.com.zone
zone ys.com/IN: loaded serial 0
OK
[root@v1 named]# systemctl restart named
[root@bogon ~]# host www.ys.com
www.ys.com has address 192.168.2.100 第一个结果为192.168.2.100
www.ys.com has address 192.168.2.101
www.ys.com has address 192.168.2.102
www.ys.com has address 192.168.2.103
[root@bogon ~]# host www.ys.com
www.ys.com has address 192.168.2.101 第二个结果为 192.168.2.101
www.ys.com has address 192.168.2.100
www.ys.com has address 192.168.2.103
www.ys.com has address 192.168.2.102
[root@bogon ~]# host www.ys.com
www.ys.com has address 192.168.2.102 第三个结果为 192.168.2.102
www.ys.com has address 192.168.2.103
www.ys.com has address 192.168.2.100
www.ys.com has address 192.168.2.101
[root@bogon ~]# host www.ys.com
www.ys.com has address 192.168.2.103 第四个结果为 192.168.2.103
www.ys.com has address 192.168.2.102
www.ys.com has address 192.168.2.101
www.ys.com has address 192.168.2.100
[root@v1 named]# vim ys.com.zone
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS v1
v1 A 192.168.2.10
* A 192.168.2.100
这里的*是通配符
[root@v1 named]# named-checkzone ys.com ys.com.zone
zone ys.com/IN: loaded serial 0
OK
[root@v1 named]# systemctl restart named
[root@bogon ~]# nslookup www.ys.com
Server: 192.168.2.10
Address: 192.168.2.10#53
Name: www.ys.com
Address: 192.168.2.100
[root@bogon ~]# nslookup bbs.ys.com
Server: 192.168.2.10
Address: 192.168.2.10#53
Name: bbs.ys.com
Address: 192.168.2.100
[root@bogon ~]# nslookup yyy.ys.com
Server: 192.168.2.10
Address: 192.168.2.10#53
Name: yyy.ys.com
Address: 192.168.2.100
[root@v1 ~]# vim /etc/named.conf
options {
directory "/var/named"; 地址库默认存放位置
};
zone "ys.com" IN { 指定本机服务负责解析的域名
type master; 指定本机为权威DNS服务器
file "ys.com.zone"; 指定地址库文件名称
};
[root@v1 named]# named-checkconf /etc/named.conf
没有提示什么就说明没有问题
[root@v1 named]# vim ys.com.zone
......
@ NS v1
v1 A 192.168.2.10
pc20 A 192.168.2.20 指定子域为192.168.2.20
* A 192.168.2.100
[root@v1 named]# named-checkzone ys.com ys.com.zone
zone ys.com/IN: loaded serial 0
OK
[root@v1 named]# systemctl restart named
[root@bogon named]# host www.ys.com 192.168.2.10
Using domain server:
Name: 192.168.2.10
Address: 192.168.2.10#53
Aliases:
www.ys.com has address 192.168.2.100
[root@bogon ~]# yum -y install bind*
[root@bogon ~]# cp -p /etc/named.conf /etc/named.conf.bbk //备份默认主配置文件
[root@bogon ~]# vim /etc/named.conf
options {
directory "/var/named";
};
zone "sz.ys.com" IN {
type master;
file "sz.ys.com.zone";
};
[root@bogon ~]# named-checkconf /etc/named.conf //检查主配置文件书写是否正确
[root@bogon ~]# cd /var/named/
[root@bogon named]# cp -p named.localhost sz.ys.com.zone 参考范本创建地址库文件
[root@bogon named]# vim sz.ys.com.zone
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS pc20 sz.ys.com这个域名是pc20.sz.ys.com这台服务器负责
pc20 A 192.168.2.20 pc20.sz.ys.com这台服务器IP地址是192.168.2.10
www A 8.8.8.8 www.sz.ys.com这个域名对应的IP地址是8.8.8.8
[root@bogon named]# named-checkzone sz.ys.com sz.ys.com.zone 检查地址库文件是否书写正确
zone sz.ys.com/IN: loaded serial 0
OK
[root@bogon named]# systemctl start named
[root@bogon named]# systemctl enable named
Created symlink from /etc/systemd/system/multi-user.target.wants/named.service to /usr/lib/systemd/system/named.service.
[root@bogon named]# host www.sz.ys.com 192.168.2.20
Using domain server:
Name: 192.168.2.20
Address: 192.168.2.20#53
Aliases:
www.sz.ys.com has address 8.8.8.8
[root@v1 nginx]# host www.sz.ys.com 192.168.2.10
Using domain server:
Name: 192.168.2.10
Address: 192.168.2.10#53
Aliases:
www.sz.ys.com has address 192.168.2.100
[root@v1 nginx]# host www.sz.ys.com 192.168.2.10
Using domain server:
Name: 192.168.2.10
Address: 192.168.2.10#53
Aliases:
Host www.sz.ys.com not found: 3(NXDOMAIN)
[root@v1 ~]# cd /var/named/
[root@v1 ~]# vim ys.com.zone
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS v1
sz.ys.com. NS pc20.sz.ys.com.
v1 A 192.168.2.10
pc20.sz.ys.com. A 192.168.2.20
* A 192.168.2.100
[root@v1 named]# systemctl restart named 重启服务
[root@v1 named]# host www.sz.ys.com 192.168.2.10
Using domain server:
Name: 192.168.2.10
Address: 192.168.2.10#53
Aliases:
www.sz.ys.com has address 8.8.8.8
[root@bogon named]# host www.qq.com
www.qq.com has address 157.255.192.44
www.qq.com has address 61.241.44.148
[root@bogon named]# host www.qq.com 202.106.0.20 --国内公共DNS服务器之一
Using domain server:
Name: 202.106.0.20
Address: 202.106.0.20#53
Aliases:
www.qq.com has address 157.255.192.44
www.qq.com has address 61.241.44.148
;; connection timed out; no servers could be reached
www.qq.com is an alias for public-v6.sparta.mig.tencent-cloud.net.
[root@pc20 ~]# yum -y install bind*
[root@pc20 ~]# vim /etc/named.conf
options {
forwarders { 202.106.0.20; }; 转发给202.106.0.20DNS服务器
};
[root@pc20 ~]# named-checkconf /etc/named.conf 检查主配置文件是否书写正确
[root@pc20 ~]# systemctl start named
[root@pc20 ~]# systemctl enable named
[root@pc20 ~]# host www.baidu.com 192.168.2.20 查询百度站点IP
Using domain server:
Name: 192.168.2.20
Address: 192.168.2.20#53
Aliases:
www.baidu.com is an alias for www.a.shifen.com.
www.a.shifen.com has address 163.177.151.110
www.a.shifen.com has address 163.177.151.109
[root@pc20 ~]# host www.163.com 192.168.2.20 查询网易的站点IP
Using domain server:
Name: 192.168.2.20
Address: 192.168.2.20#53
Aliases:
www.163.com is an alias for www.163.com.163jiasu.com.
www.163.com.163jiasu.com is an alias for www.163.com.bsgslb.cn.
www.163.com.bsgslb.cn is an alias for z163ipv6.v.bsgslb.cn.
z163ipv6.v.bsgslb.cn has address 112.90.70.74
z163ipv6.v.bsgslb.cn has address 112.90.70.67
z163ipv6.v.bsgslb.cn has address 112.90.70.69
z163ipv6.v.bsgslb.cn has address 112.90.70.71
z163ipv6.v.bsgslb.cn has address 112.90.70.73
z163ipv6.v.bsgslb.cn has address 112.90.70.68
z163ipv6.v.bsgslb.cn has address 112.90.70.72
z163ipv6.v.bsgslb.cn has IPv6 address 2408:8756:c53:3::1:20
z163ipv6.v.bsgslb.cn has IPv6 address 2408:8756:c53:3::1:26
z163ipv6.v.bsgslb.cn has IPv6 address 2408:8756:c53:3::1:18
z163ipv6.v.bsgslb.cn has IPv6 address 2408:8756:c53:3::1:2a
z163ipv6.v.bsgslb.cn has IPv6 address 2408:8756:c53:3::1:28
z163ipv6.v.bsgslb.cn has IPv6 address 2408:8756:c53:3::1:1c