正向解析:根据域名查找对应的IP地址
反向解析:根据IP地址查找对应的域名
http://www.sina.com.cn./
http:主机名 子域 二级域 顶级域 根域
1、主域名服务器:
2、从域名服务器:
3、缓存域名服务器:
4、转发域名服务器:
yum -y install bind
rpm -qc bind #查询bind软件配置文件所在路径
/etc/named.conf #主配置文件
/etc/named/rfc1912.zonrs #区域配置文件
/var/named/named.localhost #区域数据配置文件
修改完成:wq保存并退出
vim /etc/named.conf
options {
listen-on port 53 { 192.168.184.10; }; #监听53端口,IP地址使用提供服务的本地IP,也可用any代表所有
# listen-on-v6 port 53 { : :1; }; # ipv6这行如果不使用,可以注释掉或者删除
directory "/var/named"; #区域数据文件的默认存放位置
dump- file "/var/ named/data/cache_ dump .db"; #域名缓存数据库文件的位置
statistics-file "/var/named/data/named stats.txt"; #状态统计文件的位置
memstatistics-file "/var/named/data/named_ mem_ stats. txt"; #内存统计文件的位置
allow-query {192.168.80.0/24;172.16.100.0/24; }
{ any; }; #允许使用本DNS解析服务的网段,也可用any代表所有
};
zone " . " IN { #正向解析“. "根区域
type hint; #类型为根区域
file "named.ca"; #区域数据文件为named.ca,记录了13台根域服务器的域名和IP地址等信息
};
include "/etc/ named. rfc1912. zones"; #包含区域配置文件里的所有配置
vim /etc/ named. rfc1912. zone #文件里有模版,可复制粘贴后修改
zone "xc.com" IN { #正向解析"lic.com"区域
type master; #类型为主区域
file "xc.com.zone"; ●指定区域数据文件为lic. com. zone
allow-update { none; };
};
cd /var/named/
cp -p named.localhost lic.com.zone #保留源文件的权限和属主的属性复制
vim /var/named/xc.com.zone
$TTL 1D #设置有效解析记录的生命周期
@ IN SOA xc.com. admin.xc.com. ( #“@”符号表示当前的DNS区域名
0 ; serial . #更新序列号,可以是10位以内的整数
1D ; refresh #刷新时间,重新下载地址数据的间隔
1H ; retry #重试延时,下载失败后的重试间隔
1W ;expire #失效时间,超过该时间仍无法下载则放弃
3H ) ;minimum #无效解析记录的生存周期
NS xc.com. #记录当前区域的DNS服务器的名称
A 192.168.92.10 #记录主机IP地址
www IN A 192.168.92.20 #记录正向解析www.benet.com对应的IP
mail IN A 192.168.92.30
ftp IN CNAME www # CNAME使用别名,ftp是www的别名
* IN A 192.168.92.100 #泛域名解析,“*"代表任意主机名
systemctl start named #启动服务
systemctl stop firewalld #关闭防火墙
setenforce 0 #关闭安全设施
vim /var/log/ messages
或者 #如果服务启动失败,可以查看日志文件来排查错误
journalctl -u named -r
rndc-confgen -r /dev/urandom -a #如果服务启动卡住,可以执行此命令解决
在Linux系统上设置DNS服务器地址的方法:
(1)vi /etc/resolv.conf #修改完后立即生效
nameserver 192.168.184.10
(2)vi /etc/ sysconfig/network- scripts/ ifcfg-ens33 #修改完后需要重启网卡
DNS1=192.168.80.10 #在dns1上设置dns服务器
systemctl restart network
host www.lic.com
nslookup www.lic.com
dig www.lic.com
vim /etc/named.conf #主配置文件
和正向设置的一样就行
/etc/named/rfc1912.zonrs #区域配置文件
找个模板来写,网段倒过来写
zone "92.168.192.in-addr.arpa" IN {
type master;
file "xc.com.zone.local";
allow-update { none; };
};
cd /var/named/
cp -p named.localhost xc.com.zone.local
vim /var/named/xc.com.zone
$TTL 1D
@ IN SOA xc.com. admin.xc.com. (
0 ; serial .
1D ; refresh
1H ; retry
1W ;expire
3H ) ;minimum
NS xc.com.
A 192.168.92.10
50 IN PTR www.xc.com.
88 IN PTR news.xc.com.
systemctl start named
systemctl stop firewalld
setenforce 0
vi /etc/resolv.conf
nameserver 192.168.92.10
nslookup 192.168.92.50
nslookup 192.168.92.88
vim /etc/named.conf
options {
listen-on port 53 { any; };
# listen-on-v6 port 53 { : :1; };
directory "/var/named";
dump- file "/var/ named/data/cache_ dump .db";
statistics-file "/var/named/data/named stats.txt";
memstatistics-file "/var/named/data/named_ mem_ stats. txt";
allow-query {any; }
};
vim /etc/ named. rfc1912. zone
zone "xc.com" IN {
type master;
file "xc.com.zone"; #正向
allow-update { none; };
};
zone "92.168.192.in-addr.arpa" IN {
type master;
file "xc.com.zone.local"; #反向
allow-update { none; };
};
cd /var/named/
cp -p named.localhost xc.com.zone
vim /var/named/xc.com.zone
@ IN SOA xc.com. admin.xc.com. (
……
NS xc.com. #正向
A 192.168.92.10
www IN A 192.168.92.20
news IN A 192.168.92.30
ftp IN CNAME www
* IN A 192.168.92.100
cp -p named.localhost xc.com.zone.local
vim /var/named/xc.com.zone.local
@ IN SOA xc.com. admin.xc.com. (
……
NS xc.com. #反向
A 192.168.92.10
20 IN A www.xc.com.
30 IN A news.xc.com.
systemctl start named
systemctl stop firewalld
setenforce 0
vi /etc/resolv.conf
nameserver 192.168.92.10
nslookup www.xc.com
nslookup news.xc.com
nslookup ftp.xc.com
nslookup 192.168.92.50
nslookup 192.168.92.88
vim /etc/named.conf
options {
listen-on port 53 { any; };
# listen-on-v6 port 53 { : :1; };
directory "/var/named";
dump- file "/var/ named/data/cache_ dump .db";
statistics-file "/var/named/data/named stats.txt";
memstatistics-file "/var/named/data/named_ mem_ stats. txt";
allow-query {any; }
};
vim /etc/ named. rfc1912. zone
zone "xc.com" IN {
type slave;
masters "192.168.92.10"; #正向
file "slaves/xc.com.zone";
};
zone "92.168.192.in-addr.arpa" IN {
type slave;
masters "192.168.92.10"; #反向
;file "slaves/xc.com.zone.local";
};
cd /var/named/
[root@localhost named]# ls
data dynamic named.ca named.empty named.localhost named.loopback slaves
systemctl start named
systemctl stop firewalld
setenforce 0
vi /etc/resolv.conf
nameserver 192.168.92.10
nslookup www.xc.com