1
2
3
4
5
6
|
magedu.com. IN SOA ns1.magedu.com. dnssdmin.magedu.com. (
2016010801
1H
10M
3D
1D )
|
1
|
magedu.com. IN NS ns1.magedu.com.
|
1
2
3
4
|
ns1 IN A 172.16.249.130
mx1 IN A 172.16.249.10
mx2 IN A 172.16.249.11
www IN A 172.16.249.130
|
1
|
web IN CNAME www
|
1
2
3
4
5
6
7
8
9
10
|
$TTL 3600
$ORIGIN 249.16.172.
in
-addr.arpa.
@ IN SOA ns1.stu61.com. tz.stu61.com. (
2016010801
1H
10M
3D
12H )
IN NS ns1.stu61.com.
130 IN PTR ns1.stu61.com.
|
1
2
|
magedu.com. IN MX 10 mx1
magedu.com. IN MX 20 mx2
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
[root@localhost named]
# cat /etc/named.conf
options {
listen-on port 53 { 172.16.249.130; };
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
{ localhost; };
logging {
channel default_debug {
file
"data/named.run"
;
severity dynamic;
};
};
zone
"."
IN {
type
hint;
file
"named.ca"
;
};
include
"/etc/named.rfc1912.zones"
;
include
"/etc/named.root.key"
;
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
[root@localhost ~]
# vim /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 {
listen-on port 53 { 172.16.249.130; };
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
{ localhost; };
/*
- If you are building an AUTHORITATIVE DNS server,
do
NOT
enable
recursion.
- If you are building a RECURSIVE (caching) DNS server, you need to
enable
recursion.
- If your recursive DNS server has a public IP address, you MUST
enable
access
control to limit queries to your legitimate
users
. Failing to
do
so will
cause your server to become part of large scale DNS amplification
attacks. Implementing BCP38 within your network would greatly
reduce such attack surface
*/
recursion
yes
;
dnssec-
enable
no;
dnssec-validation no;
dnssec-lookaside no;
/* Path to ISC DLV key */
bindkeys-
file
"/etc/named.iscdlv.key"
;
managed-keys-directory
"/var/named/dynamic"
;
pid-
file
"/run/named/named.pid"
;
session-keyfile
"/run/named/session.key"
;
};
logging {
channel default_debug {
file
"data/named.run"
;
severity dynamic;
};
};
zone
"."
IN {
type
hint;
file
"named.ca"
;
};
include
"/etc/named.rfc1912.zones"
;
include
"/etc/named.root.key"
;
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
[root@localhost ~]
# cat /var/named/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
[root@localhost ~]
# cat /var/named/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.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
[root@localhost ~]
# systemctl status named.service
named.service - Berkeley Internet Name Domain (DNS)
Loaded: loaded (
/usr/lib/systemd/system/named
.service; disabled)
Active: active (running) since Sat 2016-01-09 19:31:24 CST; 18s ago
Process: 6825 ExecStart=
/usr/sbin/named
-u named $OPTIONS (code=exited, status=0
/SUCCESS
)
Process: 6822 ExecStartPre=
/bin/bash
-c
if
[ !
"$DISABLE_ZONE_CHECKING"
==
"yes"
];
then
/usr/sbin/named-checkconf
-z
/etc/named
.conf;
else
echo
"Checking of zone files is disabled"
;
fi
(code=exited, status=0
/SUCCESS
)
Main PID: 6827 (named)
CGroup:
/system
.slice
/named
.service
?..6827
/usr/sbin/named
-u named
Jan 09 19:31:23 localhost.localdomain named[6827]: zone 0.
in
-addr.arpa
/IN
: loaded serial 0
Jan 09 19:31:24 localhost.localdomain named[6827]: zone 1.0.0.127.
in
-addr.arpa
/IN
: loaded serial 0
Jan 09 19:31:24 localhost.localdomain named[6827]: 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....l 0
Jan 09 19:31:24 localhost.localdomain named[6827]: zone localhost
/IN
: loaded serial 0
Jan 09 19:31:24 localhost.localdomain named[6827]: zone localhost.localdomain
/IN
: loaded serial 0
Jan 09 19:31:24 localhost.localdomain named[6827]: all zones loaded
Jan 09 19:31:24 localhost.localdomain named[6827]: running
Jan 09 19:31:24 localhost.localdomain systemd[1]: Started Berkeley Internet Name Domain (DNS).
Jan 09 19:31:24 localhost.localdomain named[6827]: error (network unreachable) resolving
'./DNSKEY/IN'
: ...
#53
Jan 09 19:31:24 localhost.localdomain named[6827]: error (network unreachable) resolving
'./NS/IN'
: 2001...
#53
Hint: Some lines were ellipsized, use -l to show
in
full.
|
1
2
3
4
5
|
[root@localhost ~]
# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID
/Program
name
tcp 0 0 172.16.249.130:53 0.0.0.0:* LISTEN 6827
/named
udp6 0 0 ::1:53 :::* 6827
/named
|
1
2
3
4
5
|
[root@localhost ~]
# vim /etc/resolv.conf
# Generated by NetworkManager
search magelinux.com
nameserver 172.16.249.130
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
[root@localhost ~]
# dig -t A www.baidu.com
; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.1 <<>> -t A www.baidu.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR,
id
: 7319
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 5, ADDITIONAL: 6
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.baidu.com. IN A
;; ANSWER SECTION:
www.baidu.com. 103 IN CNAME www.a.shifen.com.
www.a.shifen.com. 300 IN A 61.135.169.121
www.a.shifen.com. 300 IN A 61.135.169.125
;; AUTHORITY SECTION:
a.shifen.com. 103 IN NS ns1.a.shifen.com.
a.shifen.com. 103 IN NS ns5.a.shifen.com.
a.shifen.com. 103 IN NS ns2.a.shifen.com.
a.shifen.com. 103 IN NS ns4.a.shifen.com.
a.shifen.com. 103 IN NS ns3.a.shifen.com.
;; ADDITIONAL SECTION:
ns3.a.shifen.com. 103 IN A 61.135.162.215
ns4.a.shifen.com. 103 IN A 115.239.210.176
ns5.a.shifen.com. 103 IN A 119.75.222.17
ns1.a.shifen.com. 103 IN A 61.135.165.224
ns2.a.shifen.com. 103 IN A 180.149.133.241
;; Query
time
: 138 msec
;; SERVER: 172.16.249.130
#53(172.16.249.130)
;; WHEN: Sat Jan 09 20:32:50 CST 2016
;; MSG SIZE rcvd: 271
|
1
2
3
4
5
6
7
8
9
10
|
[root@localhost ~]
# host -t A www.baidu.com
www.baidu.com is an
alias
for
www.a.shifen.com.
www.a.shifen.com has address 61.135.169.121
www.a.shifen.com has address 61.135.169.125
[root@localhost ~]
# host -t NS baidu.com
baidu.com name server ns2.baidu.com.
baidu.com name server ns7.baidu.com.
baidu.com name server ns4.baidu.com.
baidu.com name server dns.baidu.com.
baidu.com name server ns3.baidu.com.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[root@localhost ~]
# nslookup
>
>
set
q=A
> www.baidu.com
Server: 172.16.249.130
Address: 172.16.249.130
#53
Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 61.135.169.125
Name: www.a.shifen.com
Address: 61.135.169.121
|
1
2
3
4
5
|
[root@localhost ~]
# vim /etc/named.rfc1912.zones
zone
"stu61.com"
IN {
type
master;
file
"stu61.com.zone"
;
};
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[root@localhost named]
# vim stu61.com.zone
$TTL 3600
@ IN SOA ns1.stu61.com. tz.stu61.com. (
2016010801
1H
10M
3D
1D )
@ IN NS ns1.stu61.com.
IN MX 10 mx1
IN MX 20 mx2
ns1 IN A 172.16.249.130
mx1 IN A 172.16.249.10
mx2 IN A 172.16.249.11
www IN A 172.16.249.130
web IN CNAME www
|
1
|
[root@localhost named]
# named-checkconf
|
1
2
3
|
[root@localhost named]
# named-checkzone stu61.com /var/named/stu61.com.zone
zone stu61.com
/IN
: loaded serial 2016010801
OK
|
1
2
|
[root@localhost named]
# rndc reload
server reload successful
|
1
|
[root@localhost named]
# systemctl reload named.service
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
[root@localhost named]
# dig -t www.stu61.com
;; Warning, ignoring invalid
type
www.stu61.com
; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.1 <<>> -t www.stu61.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR,
id
: 10248
;; flags: qr rd ra; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 25
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;. IN NS
;; ANSWER SECTION:
. 511058 IN NS e.root-servers.net.
. 511058 IN NS g.root-servers.net.
. 511058 IN NS m.root-servers.net.
. 511058 IN NS k.root-servers.net.
. 511058 IN NS a.root-servers.net.
. 511058 IN NS i.root-servers.net.
. 511058 IN NS d.root-servers.net.
. 511058 IN NS h.root-servers.net.
. 511058 IN NS b.root-servers.net.
. 511058 IN NS f.root-servers.net.
. 511058 IN NS c.root-servers.net.
. 511058 IN NS j.root-servers.net.
. 511058 IN NS l.root-servers.net.
;; ADDITIONAL SECTION:
a.root-servers.net. 601418 IN A 198.41.0.4
a.root-servers.net. 601418 IN AAAA 2001:503:ba3e::2:30
b.root-servers.net. 601418 IN A 192.228.79.201
b.root-servers.net. 601418 IN AAAA 2001:500:84::b
c.root-servers.net. 601417 IN A 192.33.4.12
c.root-servers.net. 601417 IN AAAA 2001:500:2::c
d.root-servers.net. 601414 IN A 199.7.91.13
d.root-servers.net. 601414 IN AAAA 2001:500:2d::d
e.root-servers.net. 601416 IN A 192.203.230.10
f.root-servers.net. 601416 IN A 192.5.5.241
f.root-servers.net. 601416 IN AAAA 2001:500:2f::f
g.root-servers.net. 601418 IN A 192.112.36.4
h.root-servers.net. 601415 IN A 198.97.190.53
h.root-servers.net. 601416 IN AAAA 2001:500:1::53
i.root-servers.net. 601414 IN A 192.36.148.17
i.root-servers.net. 601414 IN AAAA 2001:7fe::53
j.root-servers.net. 601417 IN A 192.58.128.30
j.root-servers.net. 601417 IN AAAA 2001:503:c27::2:30
k.root-servers.net. 601415 IN A 193.0.14.129
k.root-servers.net. 601415 IN AAAA 2001:7fd::1
l.root-servers.net. 601418 IN A 199.7.83.42
l.root-servers.net. 601418 IN AAAA 2001:500:3::42
m.root-servers.net. 601416 IN A 202.12.27.33
m.root-servers.net. 601416 IN AAAA 2001:dc3::35
;; Query
time
: 2 msec
;; SERVER: 172.16.249.130
#53(172.16.249.130)
;; WHEN: Sat Jan 09 21:33:46 CST 2016
;; MSG SIZE rcvd: 755
|
1
2
|
[root@localhost named]
# chown :named stu61.com.zone
[root@localhost named]
# chmod o= stu61.com.zone
|
1
2
3
4
5
|
[root@localhost named]
# vim /etc/named.rfc1912.zones
zone
"249.16.172.in-addr.arpa"
IN {
type
master;
file
"172.16.249.zone"
;
};
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@localhost named]
# vim 172.16.249.zone
$TTL 3600
$ORIGIN 249.16.172.
in
-addr.arpa.
@ IN SOA ns1.stu61.com. tz.stu61.com. (
2016010801
1H
10M
3D
12H )
IN NS ns1.stu61.com.
130 IN PTR ns1.stu61.com.
10 IN PTR mx1.stu61.com.
11 IN PTR mx2.stu61.com.
130 IN PTR www.stu61.com.
|
1
|
[root@localhost named]
# named-checkconf
|
1
2
3
|
[root@localhost named]
# named-checkzone 249.16.172.in-addr.arpa 172.16.249.zone
zone 249.16.172.
in
-addr.arpa
/IN
: loaded serial 2016010801
OK
|
1
2
|
[root@localhost named]
# rndc reload
server reload successful
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
[root@localhost named]
# dig -x 172.16.249.130
; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.1 <<>> -x 172.16.249.130
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR,
id
: 6749
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 2
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;130.249.16.172.
in
-addr.arpa. IN PTR
;; ANSWER SECTION:
130.249.16.172.
in
-addr.arpa. 3600 IN PTR www.stu61.com.
130.249.16.172.
in
-addr.arpa. 3600 IN PTR ns1.stu61.com.
;; AUTHORITY SECTION:
249.16.172.
in
-addr.arpa. 3600 IN NS ns1.stu61.com.
;; ADDITIONAL SECTION:
ns1.stu61.com. 3600 IN A 172.16.249.130
;; Query
time
: 1 msec
;; SERVER: 172.16.249.130
#53(172.16.249.130)
;; WHEN: Sat Jan 09 22:04:58 CST 2016
;; MSG SIZE rcvd: 131
|
1
2
|
[root@localhost named]
# chmod o= 172.16.249.zone
[root@localhost named]
# chown :named 172.16.249.zone
|