#前提准备:关闭SElinux 关闭防火墙 时间同步
#环境说明:Centos7
#ip地址:dns-master:10.0.0.100 dns-slave:10.0.0.103 web:10.0.0.101
yum install bind -y
vim /etc/named.conf
#注释掉下面两行
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
#加上此项,只允许从服务器进行区域传输
allow-transfer { 10.0.0.103; };
vim /etc/named.rfc1912.zones
#加上这段
zone "zhang.org" {
type master;
file "zhang.org.zone";
};
named-checkconf
#-p选项保留属性,不然运行程序的named用户没有权限
cp -p /var/named/named.localhost /var/named/zhang.org.zone
vim /var/named/zhang.org.zone
$TTL 1D
@ IN SOA master admin.zhang.org. (
20230327 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master
NS slave
master A 10.0.0.100
slave A 10.0.0.103
www A 10.0.0.101
named-checkzone "zhang.org" /var/named/zhang.org.zone
systemctl start named
yum install -y bind
vim /etc/named.conf
#注释掉下面两行
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
#不允许其它主机进行区域传输
allow-transfer { none;};
vim /etc/named.rfc1912.zones
#加上这段
zone "zhang.org" {
type slave;
masters { 10.0.0.100; };
file "slaves/zhang.org.slave";
};
systemctl start named
ls /var/named/slaves/zhang.org.slave
yum install -y httpd
systemctl start httpd
vim /etc/sysconfig/network-scripts/ifcfg-ens32
#修改DNS地址
DNS1=10.0.0.100
DNS2=10.0.0.103
#dig命令需要安装bind-utils这个包
dig www.zhang.org
curl www.zhang.org
systemctl stop named
dig www.zhang.org
curl www.zhang.org
#前提准备:关闭SElinux 关闭防火墙 时间同步
#环境说明:Centos7
#ip地址:
DNS父域服务器:10.0.0.100 父域的web服务器:10.0.0.102,www.zhang.org
DNS子域服务器:10.0.0.101 子域的web服务器:10.0.0.103,www.bj.zhang.org
yum install -y bind
vim /etc/named.conf
#注释掉下面两行
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
#加上此项,只允许子域服务器进行区域传输
allow-transfer { 10.0.0.101;};
#关闭加密验证
dnssec-enable no;
dnssec-validation no;
vim /etc/named.rfc1912.zones
#加上这段
zone "zhang.org" {
type master;
file "zhang.org.zone";
};
#-p选项保留属性,不然运行程序的named用户没有权限
cp -p /var/named/named.localhost /var/named/zhang.org.zone
vim /var/named/zhang.org.zone
$TTL 1D
@ IN SOA master admin.zhang.org. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master
NS bj
master A 10.0.0.100
bj A 10.0.0.101
www A 10.0.0.102
systemctl start named
yum install -y bind
vim /etc/named.conf
#注释掉下面两行
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
#加上此项
allow-transfer { none;};
vim /etc/named.rfc1912.zones
zone "bj.wang.org" {
type master;
file "bj.wang.org.zone";
};
#-p选项保留属性,不然运行程序的named用户没有权限
cp -p /var/named/named.localhost /var/named/zhang.org.zone
vim /var/named/bj.zhang.org.zone
$TTL 1D
@ IN SOA master admin.zhang.org. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master
master A 10.0.0.101
www A 10.0.0.103
yum install -y httpd
systemctl start httpd
#前提准备:关闭SElinux 关闭防火墙 时间同步
#环境说明:Centos7
#ip地址:DNS转发服务器:10.0.0.100 DNS主服务器:10.0.0.101 web服务器:10.0.0.102
yum install -y bind
vim /etc/named.conf
#注释掉两行
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
#加上此项,设定转发机制和转发地址
forward first;
forwarders { 10.0.0.101;};
#关闭dnsec功能
dnssec-enable no;
dnssec-validation no;
systemctl start named
yum install -y bind
vim /etc/named.conf
#注释掉两行
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
vim /etc/named.rfc1912.zones
#加上下面这段
zone "zhang.org" {
type master;
file "zhang.org.zone";
};
#-p选项保留属性,不然运行程序的named用户没有权限
cp -p /var/named/named.localhost /var/named/zhang.org.zone
vim /var/named/zhang.org.zone
$TTL 1D
@ IN SOA master admin.zhang.org. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS master
master A 10.0.0.101
websrv A 10.0.0.102
www CNAME webbsrv
systemctl start named
yum install -y httpd
systemctl start httpd
#前提准备:关闭SElinux 关闭防火墙 时间同步
#环境说明:Centos7
#ip地址:主DNS服务器:10.0.0.100,192.168.10.100 客户端:10.0.0.101,192.168.10.101
上海用户访问www.zhang.org,DNS服务器将域名解析为10.0.0.102的ip返回给用户进行访问
北京用户访问www.zhang.org,DNS服务器将域名解析为192.168.10.102的ip返回给用户进行访问
yum install -y bind
2: ens32: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:d0:4a:61 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.100/24 brd 10.0.0.255 scope global noprefixroute ens32
valid_lft forever preferred_lft forever
inet6 fe80::c39a:6fea:e4fa:d5ca/64 scope link tentative noprefixroute dadfailed
valid_lft forever preferred_lft forever
inet6 fe80::2389:c758:d23a:151a/64 scope link tentative noprefixroute dadfailed
valid_lft forever preferred_lft forever
inet6 fe80::a2a0:1936:99b1:d760/64 scope link tentative noprefixroute dadfailed
valid_lft forever preferred_lft forever
3: ens33: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:d0:4a:6b brd ff:ff:ff:ff:ff:ff
inet 192.168.10.100/24 brd 192.168.10.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fed0:4a6b/64 scope link
valid_lft forever preferred_lft forever
vim /etc/named.conf
#注释掉两行
// listen-on port 53 { 127.0.0.1; };
// allow-query { localhost; };
#加上这段
acl shanghainet {
10.0.0.0/24;
};
acl beijingnet {
192.168.10.0/24;
};
#将下面这段剪切至/etc/named.rfc1912.zones中
zone "." IN {
type hint;
file "named.ca";
};
cp -p /etc/named.rfc1912.zones /etc/named.rfc1912.zones.sh
cp -p /etc/named.rfc1912.zones /etc/named.rfc1912.zones.bj
vim /etc/named.conf
#注释此行
// include "/etc/named.rfc1912.zones";
#加上下面两段
view shanghai {
match-clients { shanghainet;};
include "/etc/named.rfc1912.zones.sh";
};
view beijing {
match-clients { beijingnet;};
include "/etc/named.rfc1912.zones.bj";
};
vim /etc/named.rfc1912.zones.sh
#加上这段
zone "zhang.org" {
type master;
file "zhang.org.zone.sh";
};
vim /etc/named.rfc1912.zones.bj
#加上这段
zone "zhang.org" {
type master;
file "zhang.org.zone.bj";
};
systemctl start named
#10.0.0.101充当上海用户,192.168.10.101充当北京用户