1、本机DNS配置
[root@iZ23mdqdp94Z ~]# cat /etc/resolv.conf
options timeout:1 attempts:1 rotate
nameserver 10.202.72.116
nameserver 10.202.72.118
[root@iZ23mdqdp94Z ~]#
2、dns服务器搭建
[root@iZ23mdqdp94Z ~]# yum install bind
cache文件:设置DNS服务器查询域名解析后的结果(域名与IP地址的对应关系)。
正向解析区域:zone完成域名到IP地址的对应转换工作。
反向解析区域:reverse zone完成从ip到域名的对应转换工作。
[root@iZ23mdqdp94Z ~]# vi /etc/named.conf
//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {
........
# 从/var/named目录下读取DNS数据文件
directory "/var/named";
......
}
@H_502_45@本博客所有内容是原创,如果转载请注明来源
http://blog.csdn.net/myhaspl/
named从name.ca文件中获得internet的顶层根服务器地址。
zone "." IN {
type hint;
file "named.ca";
};
[root@iZ23mdqdp94Z named]# cat named.ca
; <<>> DiG 9.9.2-P1-RedHat-9.9.2-6.P1.fc18 <<>> +bufsize=1200 +norec @a.root-servers.net
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY,status: NOERROR,id: 25828
;; flags: qr aa; QUERY: 1,ANSWER: 13,AUTHORITY: 0,ADDITIONAL: 23
;; OPT PSEUDOSECTION:
; EDNS: version: 0,flags:; udp: 512
;; QUESTION SECTION:
;. IN NS
;; ANSWER SECTION:
. 518400 IN NS a.root-servers.net.
. 518400 IN NS b.root-servers.net.
. 518400 IN NS c.root-servers.net.
. 518400 IN NS d.root-servers.net.
. 518400 IN NS e.root-servers.net.
. 518400 IN NS f.root-servers.net.
. 518400 IN NS g.root-servers.net.
. 518400 IN NS h.root-servers.net.
. 518400 IN NS i.root-servers.net.
. 518400 IN NS j.root-servers.net.
. 518400 IN NS k.root-servers.net.
. 518400 IN NS l.root-servers.net.
. 518400 IN NS m.root-servers.net.
;; ADDITIONAL SECTION:
a.root-servers.net. 3600000 IN A 198.41.0.4
a.root-servers.net. 3600000 IN AAAA 2001:503:ba3e::2:30
b.root-servers.net. 3600000 IN A 192.228.79.201
c.root-servers.net. 3600000 IN A 192.33.4.12
d.root-servers.net. 3600000 IN A 199.7.91.13
d.root-servers.net. 3600000 IN AAAA 2001:500:2d::d
e.root-servers.net. 3600000 IN A 192.203.230.10
f.root-servers.net. 3600000 IN A 192.5.5.241
f.root-servers.net. 3600000 IN AAAA 2001:500:2f::f
g.root-servers.net. 3600000 IN A 192.112.36.4
h.root-servers.net. 3600000 IN A 128.63.2.53
h.root-servers.net. 3600000 IN AAAA 2001:500:1::803f:235
i.root-servers.net. 3600000 IN A 192.36.148.17
i.root-servers.net. 3600000 IN AAAA 2001:7fe::53
j.root-servers.net. 3600000 IN A 192.58.128.30
j.root-servers.net. 3600000 IN AAAA 2001:503:c27::2:30
k.root-servers.net. 3600000 IN A 193.0.14.129
k.root-servers.net. 3600000 IN AAAA 2001:7fd::1
l.root-servers.net. 3600000 IN A 199.7.83.42
l.root-servers.net. 3600000 IN AAAA 2001:500:3::42
m.root-servers.net. 3600000 IN A 202.12.27.33
m.root-servers.net. 3600000 IN AAAA 2001:dc3::35
;; Query time: 78 msec
;; SERVER: 198.41.0.4#53(198.41.0.4)
;; WHEN: Mon Jan 28 15:33:31 2013
;; MSG SIZE rcvd: 699
下面是另外一个文件:
[root@iZ23mdqdp94Z ~]# cat /etc/named.rfc1912.zones
// named.rfc1912.zones:
//
// Provided by Red Hat caching-nameserver package
//
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
// and http://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt
// (c)2007 R W Franks
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
zone "localhost.localdomain" IN {
type master;
file "named.localhost";
allow-update { none; };
};
zone "localhost" IN {
type master;
file "named.localhost";
allow-update { none; };
};
zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
type master;
file "named.loopback";
allow-update { none; };
};
zone "1.0.0.127.in-addr.arpa" IN {
type master;
file "named.loopback";
allow-update { none; };
};
zone "0.in-addr.arpa" IN {
type master;
file "named.empty";
allow-update { none; };
};
1、指定包含localhost的DNS文件
zone "localhost" IN {
type master;
file "named.localhost";
allow-update { none; };
};
[root@iZ23mdqdp94Z named]# cat named.localhost
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
AAAA ::1
2、指定127.0.0.1地址转换主服务器,内部lookback地址
zone "1.0.0.127.in-addr.arpa" IN {
type master;
file "named.loopback";
allow-update { none; };
};
127.0.0.1形式的地址到域名的转换。
[root@iZ23mdqdp94Z named]# cat named.loopback
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
AAAA ::1
PTR localhost.
设置详解:
一、设置根区域
zone "." IN {
type hint;
file "named.ca";
};
DNS服务器在本地区域文件不能进行查询解析时,会转到根DNS服务器查询。
二、设置主区域
1、[root@iZ23mdqdp94Z named]# vi /etc/named.conf
随意写一个自己的定义的域名myhaspllearn.com。
zone "myhaspllearn.com"{
type master;
file "named.myhaspllearn";
allow-update { none; };
}
然后,编辑named.myhaspllearn这个正向解析区域文件。
第1行:
@出现在正向解析区域文件中,如果遇到@,则可以替换成named.conf中声明的相关正向解析区域名称。比如myhaspllearn.com
IN表示网络类型Internet
SOA表示资源 记录类型,表明这是区域数据。
server.myhaspllearn.com表示域名服务器的主机名称,为这台DNS主机的完整域名
admin.server.myhaspllearn.com表示邮箱admin@server.myhaspllearn.com,此邮箱为管理员邮箱。当DNS数据更新时,会自动将相关数据发送到该邮箱中。
@ IN SOA server.myhaspllearn.com. admin.server.myhaspllearn.com.(20161008;serial10800;refresh120;retry604800;expire86400;default_ttl)@ IN NS server.myhaspllearn.com.;server IN A 120.55.69.31;localhost IN A 127.0.0.1;loopback IN CNAME localhost;