1.dns高速缓存服务搭建
服务器:yum install bing.x86_64 安装dns服务
设置ip及其网关
vim /etc/named.conf 配置dns服务文件
11 listen-on port 53 {any;}; 打开任意服务端网络接口dns端口
17 allow-query {any;}; 允许所有主机访问这台dns服务器
forwarders {114.114.114.114;};
33 dnssec-validation no 关闭网络认证
systemctl restart named 重启dns服务
vim /etc/resolv.conf 配置地址解析文件
nameserver 114.114.114.114 本机不知时访问114.114.114.114
客户机:vim /etc/resolv.conf
nameserver 172.25.254.107
dig www.baidu.com 查询baidu的ip(第二次访问时速度更快,因为访问一次后,地址解析的文件缓存到本机上)
vim /etc/named.conf
删除forwarders {114.114.114.114;};行
cd /var/named/
cp -p named.localhost westos.com.zone
vim westos.com.zone
vim /etc/named.rfc1912.zones
zone "westos.com" IN {
type master;
file "westos.com.zone";
allow-update { none; };
};
dig hello.westos.com
vim westos.com.zone
dig www.westos.com
vim /etc/named.rfc1912.zones
zone "254.25.172.in-addr.arpa" IN {
type master;
file "westos.com.ptr";
allow-update { none; };
};
cd /var/named/
cp -p named.loopback westos.com.ptr
vim westos.com.ptr
systemctl restart named重启dns服务
dig -x 172.25.254.111(-x 反向解析)
cp -p /etc/named.rfc1912.zones /etc/named.rfc1912.inter
vim /etc/named.rfc1912.inter
zone "westos.com" IN {
type master;
file "westos.com.inter";
allow-update { none; };
};
cp -p westos.com.zone westos.com.inter
vim westos.com.inter
vim /etc/named.conf
view localnet {
match-clients { 172.25.254.107; };
zone "." IN{
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones";
};
view inter {
match-clients { any; };
zone "." IN{
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.inter";
};
systemctl restart named
dig www.westos.com
5.dns机群(辅助dns):
serve中: 安装并设置dns的配置文件与前面相同
yum install bind
systemctl restart firewalld
vim /etc/named
11 listen-on port 53 {any;}; 打开任意服务端网络接口dns端口
17 allow-query {any;}; 允许所有主机访问这台dns服务器
33 dnssec-validation no 关闭网络认证
systemctl restart named 重启dns服务
vim /etc/named.rfc1912.zones
zone "westos.com" IN {
type slave; 辅助dns
masters { 172.25.254.107; }; 在172.25.254.107上下载westos.com.zone文件到slaves中
file "slaves/westos.com.zone";
allow-update { none; };
};
vim /etc/resolv.conf
nameserver 172.25.254.107
desktop中:
vim /etc/named.rfc1912.zones
zone "westos.com" IN {
type master;
file "westos.com.zone";
allow-update { none; };
also-notify { 172.25.254.207; }; 同步到的主机ip,可多个,中间用空格间隔
};
vim /var/name/westos.com.zone
dig www.westos.com
6.dns 更新
实验前备份/var/named/westos.com.zone
selinux为disabled
dns服务器:
vim /etc/named.rfc1912.zones
zone "westos.com" IN {
type master;
file "westos.com.zone";
allow-update { 172.25.254.7; }; 允许更新的主机ip
also-notify { 172.25.254.207; };
};
systemctl restart named
chmod 770 /var/named/ 权限
可更新的主机:
nsupdate 添加更新
>server 172.25.254.107
>update add test.westos.com 86400 A 172.25.254.119
>send
vim /var/named/westos.com.zone
nsupdate 删除更新
>server 172.25.254.107
>update delete test.westos.com
>send
dnssec-keygen -a HMAC-MD5 -b 128 -n HOST westos
cat Kwestos.+157+14628.private
cat Kwestos.+157+14628.key
cp /etc/rndc.key /etc/westos.key -p
systemctl restart named
vim /etc/westos.key
key "westos" {
algorithm hmac-md5;
secret "aclcI8b+xmJOpOhrpDsE7Q==";
};
vim /etc/named.conf
include "/etc/westos.key";
vim /etc/named.rfc1912.zone
zone "westos.com" IN {
type master;
file "westos.com.zone";
allow-update { key westos; };
also-notify { 172.25.254.207; };
};
systemctl restart named
scp Kwestos.+157+14628.* root@172.25.254.7:/mnt/
dig www.westos.com
vim /etc/dhcp/dhcpd.conf
cp /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf
systemctl restart named
systemctl restart dhcpd
vim /etc/dhcp/dhcpd.conf
option domain-name "westos.com";
option domain-name-servers 172.25.254.107;
default-lease-time 600;
max-lease-time 7200;
ddns-update-style interim; 开启dhcp动态域名更新服务
log-facility local7;
subnet 172.25.254.0 netmask 255.255.255.0 {
range 172.25.254.215 172.25.254.220;
option routers 172.25.254.107;
}
dhcp的基本配置在dhcp的搭建一节已经写过,若不了解请查看 https://blog.csdn.net/qq_38622229/article/details/80091414
key westos{
algorithm hmac-md5;
secret aclcI8b+xmJOpOhrpDsE7Q==;
};
zone westos.com. {
primary 127.0.0.1;
key westos;
}
systemctl restart dhcpd
hostnamectl set-hostname linux.westos.com
systemctl restart network
dig linux.westos.com