DNS域名服务器构建

  • A+
所属分类:linux基础

缓存域名服务器构建

⑴挂载镜像,安装DNS软件

mount /dev/cdrom /media

cd /media/Packages/

rpm -ivh bind-\t bind-chroot\t bind-libs\t bind-utils\t

⑵编辑配置文件

[root@tao ~]# vi /etc/named.conf

options {

listen-on port 53 {192.168.1.86 ; }; ……指向本地

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 { 192.168.1.0/24; }; ……允许谁使用

recursion yes;

dnssec-enable yes;

dnssec-validation yes;

dnssec-lookaside auto;

⑶启动DNS服务

service named start

构建主域名服务器

⑴挂载镜像,安装bind软件

mount /dev/cdrom /media

cd /media/Packages/

rpm -ivh bind-\t bind-chroot\t

⑵编辑配置文件

[root@tao ~]# vi /etc/named.conf

zone "zgxc.com" {

type master; ……类型,主服务器

正 file "zgxc.com.zone"; ……区域数据文件名

allow-transfer { 192.168.1.2; }; ……允许同步的从服务器

};

zone "1.168.192.in-addr.arpa" {

type master;

反 file "192.168.1.arpa";

allow-transfer { 192.168.1.2; };

};

⑶编辑区域正向数据文件

vi /var/named/zgxc.com.zone

$TTL 86400 (Time To Live,生存周期,秒)

@ SOA zgxc.com. admin.zgxc.com. ((@当前域,SOA,Start Of Authority,授权信息开始)

2017042701 更新序号,10位数自设;

4H 刷新时间,隔多长时间找主机同步一次

1M 重试延迟,未联系到主机,隔多长时间再去

3H 失效时间

1D 无效记录TTL,补$TTL未定义

)

IN NS ns1.zgxc.com. NS域名服务器name server

IN NS ns2.zgxc.com.

IN MX 10 mail.zgxc.com. MX邮件交换mail exchange

ns1 IN A 192.168.1.86 A地址记录,address,只用在正向解析中

ns2 IN A 192.168.1.2

www IN A 192.168.1.86

ftp IN A 192.168.1.86

study IN CNAME www 别名Canonical Name

* IN A 192.168.1.86

⑷编辑区域反向数据文件

[root@tao named]# vi /var/named/192.168.1.arpa

$TTL 86400、

@ SOA zgxc.com. admin.zgxc.com. (

2017042701

1H

10M

3D

1D

)

IN NS ns1.zgxc.com.

IN NS ns2.zgxc.com.

IN MX 10 mail.zgxc.com.

86 IN PTR ns1.zgxc.com.

2 IN PTR ns2.zgxc.com.

86 IN PTR www.zgxc.com.

86 IN PTR ftp.zgxc.com.

86 IN PTR study.zgxc.com.

⑸设置计算机DNS优先查询

[root@tao named]# vi /etc/resolv.conf

# Generated by NetworkManager

nameserver 192.168.1.86

⑹启动DNS服务

[root@tao named]# service named start

⑺验证能否正反向解析

[root@tao named]# nslookup

> www.zgxc.com

Server: 192.168.1.86

Address: 192.168.1.86#53

Name: www.zgxc.com

Address: 192.168.1.86

> 192.168.1.86

Server: 192.168.1.86

Address: 192.168.1.86#53

86.1.168.192.in-addr.arpa name = www.zgxc.com.

86.1.168.192.in-addr.arpa name = ftp.zgxc.com.

86.1.168.192.in-addr.arpa name = study.zgxc.com.

86.1.168.192.in-addr.arpa name = ns1.zgxc.com.

>

构建从域名服务器

⑴挂载镜像,安装bind软件

mount /dev/cdrom /media

cd /media/Packages/

rpm -ivh bind-\t bind-chroot\t

⑵编辑配置文件

[root@tao ~]# vi /etc/named.conf

options {

# listen-on port 53 { 127.0.0.1; };

# allow-query { localhost; };

zone "zgxc.com" {

type slave;

masters { 192.168.1.86; };

file "slaves/zgxc.com.zone";

};

zone "1.168.192.in-addr.arpa" {

type slave;

masters { 192.168.1.86; };

file "slaves/192.168.1.arpa";

};

⑶设置计算机DNS查询优先

[root@localhost ~]# vi /etc/resolv.conf

# Generated by NetworkManager

# No nameservers found; try putting DNS servers into your

# ifcfg files in /etc/sysconfig/network-scripts like so:

#

# DNS1=xxx.xxx.xxx.xxx

# DNS2=xxx.xxx.xxx.xxx

# DOMAIN=lab.foo.com bar.foo.com

nameserver 192.168.1.2

⑷启动DNS服务

[root@tao named]# service named start

⑸验证从服务器是否成功启动

[root@localhost ~]# ls /var/named/slaves/

192.168.1.arpa zgxc.com.zone

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: