安裝dns組件服務器
[root@localhost ~]# yum install -y bind bind-utilside
查看dns指向測試
[root@localhost ~]# cat /etc/resolv.confspa
查看根域配置文件rest
[root@localhost ~]# cat /var/named/named.ca日誌
配置文件orm
[root@localhost ~]# cat /etc/named.confdns
# 監聽端口域名
listen-on port 53 { 127.0.0.1; };it
# 子配置文件目錄
directory "/var/named";
# 日誌路徑
file "data/named.run";
# 絕對路徑是
# /var/named/data/named.run
# 正向解析示例
zone "123.com" IN {
type master;
file "123.com.zone";
};
# 檢測/etc/named.conf 文件語法
[root@localhost ~]# named-checkconf
[root@localhost ~]# vi /var/named/123.com.zone
$TTL 1D
@ IN SOA @ admin.123.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS ns.123.com.
IN MX 5 mail.123.com.
mail IN A 192.168.10.1
ns IN A 192.168.10.1
www IN A 192.168.10.1
bbs IN CNAME www
測試域名和對應的zone文件語法
[root@localhost ~]# named-checkzone "123.com" /var/named/123.com.zone
[root@localhost ~]# /etc/init.d/named restart
測試,其中127.0.0.1是DNS服務器的IP,在/etc/named.conf 主配置文件中指定的是127.0.0.1
[root@localhost ~]# dig @127.0.0.1 bbs.123.com
上面是正向解析,下面是反向解析
[root@localhost ~]# vi /etc/named.conf
zone "10.168.192.in-addr.arpa" IN {
type master;
file "10.168.192.zone";
};
[root@localhost ~]# vi /var/named/11.168.192.zone
[root@localhost ~]# cat /var/named/10.168.192.zone
$TTL 1D
@ IN SOA @ admin.123.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS ns.123.com.
18 IN PTR ns.123.com.
40 IN PTR mail.123.com.
測試
[root@localhost ~]# dig @127.0.0.1 -x 192.168.10.40
[root@localhost ~]# dig @127.0.0.1 -x 192.168.10.18
下面是從DNS服務器搭建
安裝dns組件
[root@localhost ~]# yum install -y bind bind-utils
[root@localhost ~]# vi /etc/named.conf
zone "123.com" IN {
type slave;
file "slaves/123.com.zone";
masters { 192.168.10.29; };
};
zone "10.168.192.in-addr.arpa" IN {
type slave;
file "slaves/10.168.192.zone";
masters { 192.168.10.29; };
};
[root@localhost ~]# /etc/init.d/named restart
至此,DNS及主從搭建完畢