9周作业
1、配置 bind 服务,实现 www.magedu.org 域名解析
主DNS服务器
yum -y install bind bind-utils
systemctl enable named.service
systemctl start named.service
vim /etc/named.conf
修改以下内容
13:listen-on port 53 { localhost; };
21:allow-query { any; };
22:allow-transfer { 10.0.0.12; }; #允许DNS数据库传送给哪台主机
36:dnssec-enable no;
37:dnssec-validation no;
rndc reload
vim /var/named/magedu.org.zone
内容如下:
$TTL 1D
@ IN SOA master admin ( 0 1D 1H 3D 1H )
NS master
NS slave
master A 10.0.0.10
slave A 10.0.0.12
www A 10.0.0.10
* A 10.0.0.10
@ A 10.0.0.10
注:括号内0表示序号,如果zone文件发生变化时,应修改序号将新的内容推送给从节点
2、配置 bind 服务,实现域名反向解析
vim /var/named/reverse.zone
内容如下:
$TTL 1D
@ IN SOA master admin.magedu.org. ( 0 1D 1H 3D 1H )
NS master.magedu.org.
NS slave.magedu.org.
10 PTR master.magedu.org.
12 PTR slave.magedu.org.
10 PTR www.magedu.org.
chown :named /var/named/magedu.org.zone
chmod 640 /var/named/magedu.org.zone
chown :named /var/named/reverse.zone
chmod 640 /var/named/reverse.zone
vim /etc/named.rfc1912.zones
增加以下内容:
12:zone "magedu.org" {
13: type master;
14: file "magedu.org.zone";
15:};
35:zone "1.10.0in-addr.arpa" {
36: type master;
37: file "reverse.zone";
38:};
named-checkconf
named-checkzone magedu.org /var/named/magedu.org.zone
named-checkzone 1.10.0.in-addr.arpa /var/named/reverse.zone
rndc reload
firewall-cmd --permanent --add-service=dns
firewall-cmd --reload
3、配置 bind 服务,实现主从 DNS 服务配置:
yum install bind bind-utils
systemctl enable named.service
systemctl start named.service
vim /etc/named.conf
修改以下配置
13:listen-on port 53 { localhost; };
21:allow-query { any; };
22:allow-transfer { none; };
vim /etc/named.rfc1912.zones
增加以下内容
12:zone "magedu.org" {
13: type slave;
14: masters { 10.0.0.10; };
15: file "slaves/magedu.org.slave.zone";
16:};
36:zone "1.10.0in-addr.arpa" {
37: type slave;
38: masters { 10.0.0.10; };
39: file "slaves/reverse.slave.zone";
40:};
named-checkconf
rndc reload
firewall-cmd --permanent --add-service=dns
firewall-cmd --reload
主DNS服务器修改magedu.org.zone
vim /var/named/magedu.org.zone
内容如下:
$TTL 1D
@ IN SOA master admin ( 1 1D 1H 3D 1H ) #序列由原来的0改为1
NS master
NS slave
k8s NS ns #增加k8s子域NS服务器
master A 10.0.0.10
slave A 10.0.0.10
ns A 10.0.0.13 #增加NS服务器A记录
www A 10.0.0.10
* A 10.0.0.10
@ A 10.0.0.10
4、 配置 bind 服务,实现子域服务器
yum -y install bind bind-utils
systemctl start named.service
systemctl enable named.service
vim /etc/named.conf
修改以下内容
13:listen-on port 53 { localhost; };
21:allow-query { any; };
vim /var/named/k8s.magedu.org.zone
内容如下:
$TTL 1D
@ IN SOA ns admin ( 0 1H 10M 1D 1H )
NS ns
ns A 10.0.0.13
master A 10.0.0.15
node A 10.0.0.16
etcd A 10.0.0.17
vim /etc/named.rfc1912.zones
第12行增加以下内容
zone "k8s.magedu.org" {
type master;
file "k8s.magedu.org.zone";
};
chown :named /var/named/k8s.magedu.org.zone
chmod 640 /var/named/k8s.magedu.org.zone
named-checkconf
named-checkzone k8s.magedu.org /var/named/k8s.magedu.org.zone
rndc reload
firewall-cmd --permanent --add-service=dns
firewall-cmd --reload
测试
dig master.k8s.magedu.org @10.0.0.13
dig node.k8s.magedu.org @10.0.0.10