环境
根域 :192.168.3.109
com服务器 :192.168.3.110
hxg.com服务器 主:192.168.3.108
从:192.168.3.107
apache主机(www.hxg.com):192.168.3.104
转发服务器 :192.168.3.101
本地DNS服务器: 192.168.3.102
测试客户端:192.168.3.103
配置www.hxg.com 主机
安装apache
$ yum -y install httpd
新建主页
$ echo "这个是www.hxg.com 的主机 192.168.3.104----->/val/www/html/index.html" > /var/www/html/index.html
启服务
$ systemctl start httpd
客户端测试
$ curl 192.168.3.104
这个是www.hxg.com 的主机 192.168.3.104----->/val/www/html/index.html
配置hxg.com主机主服务器
安装bind
$ yum -y install bind
修改配置文件
$ vim /etc/named.conf
options {
// listen-on port 53 { 127.0.0.1; };
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";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
// allow-query { localhost; };
allow-transfer {192.168.3.107;};
修改区域配置文件
$ vim /etc/named.rfc1912.zones
zone "hxg.com" IN {
type master;
file "hxg.com.zone";
};
新建区域数据库文件
$ cp -p /var/named/named.localhost /var/named/hxg.com.zone
$ vim /var/named/hxg.com.zone
$TTL 1D
@ IN SOA master admin (
3 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master
NS ns1
master A 192.168.3.108
ns1 A 192.168.3.107
web A 192.168.3.104
www CNAME web
* CNAME web
@ A 192.168.3.104
检查语法
$ named-checkconf
$ named-checkzone hxg.com /var/named/hxg.com.zone
zone hxg.com/IN: loaded serial 0
OK
启服务
$ systemctl start named
客户端测试
$ dig www.hxg.com @192.168.3.108
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> www.hxg.com @192.168.3.108
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39609
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 3
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.hxg.com. IN A
;; ANSWER SECTION:
www.hxg.com. 86400 IN CNAME web.hxg.com.
web.hxg.com. 86400 IN A 192.168.3.104
;; AUTHORITY SECTION:
hxg.com. 86400 IN NS master.hxg.com.
hxg.com. 86400 IN NS ns1.hxg.com.
;; ADDITIONAL SECTION:
master.hxg.com. 86400 IN A 192.168.3.108
ns1.hxg.com. 86400 IN A 192.168.3.107
;; Query time: 108 msec
;; SERVER: 192.168.3.108#53(192.168.3.108)
;; WHEN: 一 6月 08 18:49:20 CST 2020
;; MSG SIZE rcvd: 145
配置hxg.com主机从服务器
安装bind
$ yum -y install bind
修改主配置文件
$ vim /etc/named.conf
options {
// listen-on port 53 { 127.0.0.1; };
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";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
// allow-query { localhost; };
allow-transfer {none;};
修改域配置文件
$ vim /etc/named.rfc1912.zones
zone "hxg.com" IN {
type slave;
masters {192.168.3.108;};
file "slaves/hxg.com.zone";
};
启服务
$ systemctl start named
客户端测试
$ dig www.hxg.com @192.168.3.107
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> www.hxg.com @192.168.3.107
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2803
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 3
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.hxg.com. IN A
;; ANSWER SECTION:
www.hxg.com. 86400 IN CNAME web.hxg.com.
web.hxg.com. 86400 IN A 192.168.3.104
;; AUTHORITY SECTION:
hxg.com. 86400 IN NS master.hxg.com.
hxg.com. 86400 IN NS ns1.hxg.com.
;; ADDITIONAL SECTION:
master.hxg.com. 86400 IN A 192.168.3.108
ns1.hxg.com. 86400 IN A 192.168.3.107
;; Query time: 43 msec
;; SERVER: 192.168.3.107#53(192.168.3.107)
;; WHEN: 一 6月 08 18:55:56 CST 2020
;; MSG SIZE rcvd: 145
配置com服务器
安装bind
$ yum -y install bind
修改主配置文件
$ vim /etc/named.conf
options {
// listen-on port 53 { 127.0.0.1; };
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";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
// allow-query { localhost; };
allow-transfer {none;};
修改区域配置文件
$ vim /etc/named.rfc1912.zones
zone "com" IN {
type master;
file "com.zone";
};
新建区域数据库文件
$ cp -p /var/named/named.localhost /var/named/com.zone
$ vim /var/named/com.zone
$TTL 1D
@ IN SOA master admin (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master
hxg NS ns1
hxg NS ns2
master A 192.168.3.110
ns1 A 192.168.3.108
ns2 A 192.168.3.107
启服务
$ systemctl start named
客户端测试
$ dig www.hxg.com @192.168.3.110
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> www.hxg.com @192.168.3.110
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61047
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 3
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.hxg.com. IN A
;; ANSWER SECTION:
www.hxg.com. 78108 IN CNAME web.hxg.com.
web.hxg.com. 78108 IN A 192.168.3.104
;; AUTHORITY SECTION:
hxg.com. 86400 IN NS ns1.com.
hxg.com. 86400 IN NS ns2.com.
;; ADDITIONAL SECTION:
ns1.com. 86400 IN A 192.168.3.108
ns2.com. 86400 IN A 192.168.3.107
;; Query time: 63 msec
;; SERVER: 192.168.3.110#53(192.168.3.110)
;; WHEN: 一 6月 08 19:04:10 CST 2020
;; MSG SIZE rcvd: 142
配置根域
安装bind
$ yum -y install bind
配置主文件
$ vim /etc/named.conf
options {
// listen-on port 53 { 127.0.0.1; };
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";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
// allow-query { localhost; };
allow-transfer {none;};
zone "." IN {
type master;
file "root.zone";
};
新建区域数据库文件
$ cp -p /var/named/named.localhost /var/named/root.zone
$ vim /var/named/root.zone
$TTL 1D
@ IN SOA root admin (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS root
com NS ns1
root A 192.168.3.109
ns1 A 192.168.3.110
启服务
$ systemctl start named
客户端测试
$ dig www.hxg.com @192.168.3.109
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> www.hxg.com @192.168.3.109
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33607
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 3
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.hxg.com. IN A
;; ANSWER SECTION:
www.hxg.com. 78263 IN CNAME web.hxg.com.
web.hxg.com. 78263 IN A 192.168.3.104
;; AUTHORITY SECTION:
hxg.com. 78263 IN NS ns1.com.
hxg.com. 78263 IN NS ns2.com.
;; ADDITIONAL SECTION:
ns2.com. 78263 IN A 192.168.3.107
ns1.com. 78263 IN A 192.168.3.108
;; Query time: 47 msec
;; SERVER: 192.168.3.109#53(192.168.3.109)
;; WHEN: 一 6月 08 19:09:10 CST 2020
;; MSG SIZE rcvd: 142
配置转发服务器
安装bind
$ yum -y install bind
修改主配置文件
$ vim /etc/named.conf
options {
// listen-on port 53 { 127.0.0.1; };
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";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
// allow-query { localhost; };
dnssec-enable no;
dnssec-validation no;
修改根域数据库文件
$ vim /var/named/named.ca
. 518400 IN NS a.root-servers.net.
a.root-servers.net. 518400 IN A 192.168.3.109
启服务
$ systemctl start named
客户端测试
$ dig www.hxg.com @192.168.3.101
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> www.hxg.com @192.168.3.101
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40228
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 3
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.hxg.com. IN A
;; ANSWER SECTION:
www.hxg.com. 78364 IN CNAME web.hxg.com.
web.hxg.com. 78364 IN A 192.168.3.104
;; AUTHORITY SECTION:
hxg.com. 78363 IN NS ns2.com.
hxg.com. 78363 IN NS ns1.com.
;; ADDITIONAL SECTION:
ns2.com. 83787 IN A 192.168.3.107
ns1.com. 83787 IN A 192.168.3.108
;; Query time: 0 msec
;; SERVER: 192.168.3.101#53(192.168.3.101)
;; WHEN: 一 6月 08 19:14:47 CST 2020
;; MSG SIZE rcvd: 142
配置本地DNS服务器
安装bind
$ yum -y install bind
配置主配置文件
$ vim /etc/named.conf
options {
// listen-on port 53 { 127.0.0.1; };
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";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { any; };
allow-transfer {none;};
forward first ;
forwarders {192.168.3.101;};
dnssec-enable no;
dnssec-validation no;
启服务
$ systemctl start named
客户端测试
$ dig www.hxg.com @192.168.3.102
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> www.hxg.com @192.168.3.102
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11810
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 3
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.hxg.com. IN A
;; ANSWER SECTION:
www.hxg.com. 78136 IN CNAME web.hxg.com.
web.hxg.com. 78136 IN A 192.168.3.104
;; AUTHORITY SECTION:
hxg.com. 78135 IN NS ns2.com.
hxg.com. 78135 IN NS ns1.com.
;; ADDITIONAL SECTION:
ns2.com. 83559 IN A 192.168.3.107
ns1.com. 83559 IN A 192.168.3.108
;; Query time: 0 msec
;; SERVER: 192.168.3.102#53(192.168.3.102)
;; WHEN: 一 6月 08 19:18:35 CST 2020
;; MSG SIZE rcvd: 142
标签:named,架构,192.168,域名,file,internet,var,hxg,com
From: https://www.cnblogs.com/guangdelw/p/17300913.html