实现互联网架构DNS服务
DNS架构.png
注意:
- 从后往前搭建,好测试
- 测试时注意rndc flush,因为有缓存时优先使用缓存
-
配置www主机:
-
yum install -y httpd
-
vim /var/www/html/index.html
Welcome to magedu!
-
systemctl start httpd
-
-
配置主DNS:
-
vim /etc/named.conf
-
listen-on port 53 { localhost; };
-
allow-query { any; };
-
allow-transfer { 192.168.39.75; };
-
dnssec-enable no;
-
dnssec-validation no;
-
-
vim /etc/named.rfc1912.zones
-
zone "magedu.com" IN {
-
type master;
-
file "magedu.com.zone";
-
};
-
-
named-checkconf
-
vim /var/named/magedu.com.zone
-
$TTL 1D
-
@ IN SOA dns1 admin (
-
2018072401
-
1D
-
2H
-
3D
-
1D )
-
NS dns1
-
NS dns2
-
dns1 A 192.168.39.74
-
dns2 A 192.168.31.75
-
www A 192.168.31.76
-
-
chmod 640 magedu.com.zone
-
chown :named magedu.com.zone
-
named-checkzone magedu.com. magedu.com.zone
-
systemctl start named
-
-
配置从DNS:
-
vim /etc/named.conf
-
listen-on port 53 { localhost; };
-
allow-query { any; };
-
allow-transfer { 192.168.39.75; };
-
dnssec-enable no;
-
dnssec-validation no;
-
-
vim /etc/named.rfc1912.zones
-
zone "magedu.com" IN {
-
type slave;
-
masters { 192.168.39.74; };
-
file "slaves/magedu.com.slave.zone";
-
};
-
-
named-checkconf
-
systemctl start named
-
-
配置comDNS:
-
vim /etc/named.conf
-
listen-on port 53 { localhost; };
-
allow-query { any; };
-
dnssec-enable no;
-
dnssec-validation no;
-
-
vim /etc/named.rfc1912.zones
-
zone "com" IN {
-
type master;
-
file "com.zone";
-
};
-
-
named-checkconf
-
vim /var/named/com.zone
-
$TTL 1D
-
@ IN SOA dns1 admin (
-
2018072401
-
1D
-
2H
-
3D
-
1D )
-
NS dns1
-
magedu NS dns2
-
magedu NS dns3
-
dns1 A 192.168.39.73
-
dns2 A 192.168.39.74
-
dns3 A 192.168.39.75
-
-
chmod 640 com.zone
-
chown :named com.zone
-
named-checkzone com. com.zone
-
systemctl start named
-
-
配置根DNS:
-
vim /etc/named.conf
-
listen-on port 53 { localhost; };
-
allow-query { any; };
-
dnssec-enable no;
-
dnssec-validation no;
-
-
zone "." IN {
-
type master;
-
file "root.zone";
-
};
-
-
named-checkconf
-
vim /var/named/root.zone
-
$TTL 1D
-
@ IN SOA dns1 admin (
-
2018072401
-
1D
-
2H
-
3D
-
1D )
-
NS dns1
-
com NS dns2
-
dns1 A 192.168.39.72
-
dns2 A 192.168.39.73
-
-
chmod 640 root.zone
-
chown :named root.zone
-
named-checkzone . root.zone
-
systemctl start named
-
-
配置局域网DNS:
-
vim /etc/named.conf
-
listen-on port 53 { localhost; };
-
allow-query { any; };
-
dnssec-enable no;
-
dnssec-validation no;
-
-
vim /var/named/named.ca
-
. 86400 IN NS dns1
-
dns1 86400 A 192.168.39.72
-
-
systemctl start named
-
-
配置client:
-
vim /etc/resolv.conf
nameserver 192.168.39.71
-
编译安装BIND
-
下载bind
- isc.org
-
编译安装bind
- tar xvf bind-9.11.0a3.tar.gz
- cd bind-9.11.0a3/
- groupadd -r -g 53 named
- useradd -r -u 53 -g 53 named
- ./configure --prefix=/usr/local/bind9 --sysconfdir=/etc/named/ --without-openssl --disable-ipv6 --disable-chroot --enable-threads
- make
- make install
-
环境变量
-
vim /etc/profile.d/named.sh
-
export PATH=/usr/local/bind9/bin:
-
/usr/local/bind9/sbin/:$PATH
-
-
-
库和头文件
-
vim /etc/ld.so.conf.d/named.conf
/usr/local/bind9/lib
-
ldconfig –v
-
ls -sv /usr/local/bind9/include /usr/include/named
-
-
man帮助
-
vim /etc/man.config | /etc/man_db.conf
MANPATH /usr/local/bind9/share/man
-
man named.conf
-
-
主配置文件
-
vim /etc/named/named.conf
-
options {
-
directory "/var/named/"
-
};
-
zone "." IN {
-
type hint;
-
file "named.ca";
-
};
-
zone "localhost" IN {
-
type master;
-
file “named.localhost";
-
allow-update {none;};
-
};
-
zone “1.0.0.127.in-addr.arpa" IN {
-
type master;
-
file "named.loopback";
-
allow-update {none;};
-
};
-
-
-
区域数据库
-
mkdir /var/named
-
named-checkconf
-
dig +norec @a.root-servers.net > /var/named/named.ca
-
vim /var/named/named.localhost
-
$TTL 1d
-
@ IN SOA localhost. admin.localhost. (
-
2016061801
-
1h
-
5m
-
7d
-
1d)
-
IN NS localhost.
-
localhost. IN A 127.0.0.1
-
-
vim /var/named/named.loopback
-
$TTL 1d
-
@ IN SOA localhost. admin.localhost. (
-
2016061801
-
1h
-
5m
-
7d
-
1d)
-
NS @
-
A 127.0.0.1
-
PTR localhost.
-
-
-
设置权限
- chmod 640 /var/named/*
- chmod 640 /etc/named/named.conf
- chgrp -R named /var/named/
- chgrp named /etc/named/named.conf
-
启动服务和测试
- man named
- named -u named -f -g -d 3 前端级别3方式运行
- named -u named 后台运行
- killall named
- ss -tuln
- tail /var/log/message
- named -u named