linux probe 十四
DNS 正向解析 域名 到 IP 。反向解析 IP 到 域名
向最近服务器dns查询叫递归查询
最近服务器向跟服务器查询叫迭代查询
有三种服务器
主服务器 13个
从属服务器
缓存服务器 作为dns的转发
yum install bind-chroot
cd /etc/named.conf 主配置文件
listen-on port 53 {any;}; 表示服务器上的所有IP(所有网卡)地址均可提供DNS域名解析服务
allow-query{any;}; 允许所有人对本服务器发送DNS查询请求
include “/ec/named.rfc1912.zones” 用来保存域名和IP地址对应关系的所在位置。
zone "linuxprobe.com" IN {
type master;服务类型,有三种,master主,slave从,hint根区域。
file "linuxprobe.com.zone";
allow-update{none;};
};
zone "10.168.192.in-addr.arpa" IN {
type master;
file "192.168.10.arpa"; ip地址段反写,固定写法
};
从/var/named目录中复制一份正向解析模板文件named.localhost
cd /var/named/
cp -a named.localhost linuxprobe.com.zone
vim linuxprobe.com.zone
$TTL1D #生存周期为1天
@ IN SOA linuxprobe.com. kevin.163.com(如果域名有故障会通知[email protected]
0;serial
1D;refresh
1H;retry
1W;expire
3H;)minimum
NS ns.linuxprobe.com. 域名服务器记录
ns IN A 192.168.10.10 地址记录(ns.linuxprobe.com)
IN MX 10 mail.linuxprobe.com.
mail IN A 192.168.10.10 地址记录 mail.linxuprobe.com
www IN A 192.168.10.10 地址记录 www.linuxprobe.com
bba IN A 192.168.10.10 地址记录bbs.linuxprobe.com
把linux系统网卡中的DNS地址参数修改成本机的IP地址。
nmtui
systemctl restart network
iptable -F
service iptables save
systemctl restart named bind的服务名叫named
nslookup 用于检测能否从DNS服务器中查询到域名与IP地址的解析记录。
ping www.linuxprobe.com
nslookup 从检查域名对应的地址
vim /etc/named.rfc1912.zones 添加反向解析配置
zone "linuxprobe.com" IN{
type master;
file "linuxprobe.com.zone";
allow-update{none;};
};
zone "10.168.192.in-addr.arpa" IN{
type master;
file "192.168.10.arpa";
};
打开另外一个虚拟机,设置从服务器
ping 192.168.10.10 确保是ping通的
在10服务器上。
vim /var/named
zone "linuxprobe.com" IN {
type master;
file "linuxprobe.com.zone";
allow-update {192.168.10.20;};只允许192.168.10.20访问
};
zone "10.168.192.in-addr.arpa" IN {
type master;
file "192.168.10.arpa";
allow-update{192.168.10.20;}允许192.168.10.20访问
};
systemctl restart named
20服务器
yum install bind
vim /etc/named.conf
11行 listen-on port 53 { any; };
17行 allow-query { any; };
vim /etc/named.rfc1912.zones
zone "linuxprobe.com" IN {
type slave;
masters { 192.168.10.10; };
file "slaves/linuxprobe.com.zone";
};
zone "10.168.192.in-addr.arpa" IN{
type slave;
masters{192.168.10.10;};
file "slaves/192.168.10.arpa";
}
systemctl restart named
cd /var/named/slaves
ls 这两个文件在named服务重启时已经从主服务器上通过过来了
nmtui 设置本机网卡的dns为本机
systemctl restart network
systemctl restart named
nslookup 可以从域名查到ip www.linuxprobe.com
tsit保证dns之间的服务器安全协议
10服务器:
dnssec-keygen -a HMAC-MD5 -b 128 -n HOST master-slave
cd /var/named/chroot/etc/
vim transfer.key 创建
key "master-slave" {
algorithm hmac-md5;
secret "上面生成好的私钥"
}
wq!
chown root:named transfer.key
chmod 640 transfer.key
ln transfer.key /etc/transfer.key
vim /etc/named.conf
在文件头添加 include "/etc/transfer.key"
18行 allow-transfer {key master-slave;};
systemctl restart named
20服务器
rm -rf /var/named/slaves/*
systemctl restart named
ls /var/named/slaves/ 没有同步,因为还没有配置加密协议
cd /var/named/chroot/etc
vim transfer.key
key "master-slave" {
algorithm hmac-md5;
secret "公钥";
}
chrown root:named transfer.key
chmod 640 transfer.key
ln transfer.key /etc/transfer.key
vim /etc/named.conf
include "/etc/transfer.key";
server 192.168.10.10 48行,不能写的太上
{
keys {master-slave;};
};
wq!
systemctl restart network
systemctl restart named
cd /var/named/slaves/
已同步
缓存服务器
还原虚拟机
添加一个网卡,桥接模式。另外一个网卡是host only
nm-connectoin-editor 让桥接模式的网卡可上网
systemctl restart network
yum install bind-chroot
vim /etc/named.conf
11行 listen-on port { any; };
17行 forwarders { 8.8.8.8 };上一级dns的地址
wq!
systemctl restart network
systemctl restart named
iptable -F
iptable save
20服务器
nmtui 设置网卡的dns为192.168.10.10
nslookup 可以查到 www.linuxprobe.com对应的ip
CDN
两块网卡,两个网段
nmtui
systemctl restart network
yum install bind-chroot
vim /etc/named.conf
11行 listen-on port 53 { any; };
17行 allow-query { any; };
删除 51-54行根域信息
wq!
vim /etc/named.rfc1912.zones
acl "china" { 122.71.115.0/24; }; 定义了一个网段 china是一个别名
acl "american" { 106.185.25.0/24; };
view "china" {
match-clients { "china"; }; 配到到当前请求者时来自china里定义的网段的时候
zone "linuxprobe.com{
type master;
file "linuxprobe.com.china";
};
};
view "american”{
match-clients { "american"; };
zone "linuxprobe.com" {
type master;
file "linuxprobe.com.american";
};
};
cd /var/named
cp -a named.localhost linuxprobe.com.china
cp -a named.localhost linuxprobe.com.american
vim linuxprobe.com.china
@TTL 1D
@ IN SOA linuxprobe.com. root.linuxprobe.com.(
0 ; serial
1D; refresh
1H;retry
1W;expire
3H);minimum
NS ns.linuxprobe.com.
ns IN A 122.71.115.10 前一个主机的一个网卡
www IN A 122.71.115.15
@TTL 1D
@ IN SOA linuxprobe.com. root.linuxprobe.com(
0;serial
1D;refresh
1H;retry
1W;expire
3H);minimum
NS ns.inuxprobe.com
ns IN A 106.185.25.10
www IN A 106.185.25.15
)
systemctl restart network
systemctl restart named
system enabled network
iptables -F
客户端可以在windows里
模拟北京用户,ip设置122.71.115.10 网关不用写 dns 122.71.115.1
ping www.linuxprobe.com
模拟国外用户,ip设置106.185.25.88 网关不写 DNS 106.185.25.1
重启网卡
ping www.linuxprobe.com