IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 系统运维 -> linux中企业dns的部署及优化 -> 正文阅读

[系统运维]linux中企业dns的部署及优化

一、安装,测试
服务器
dnf install bind -y
systemctl enable --now named
netstat -antlupe | grep named
firewall-cmd --permanent --add-service=dns
firewall-cmd --reload

##编辑named的配置文件

vim /etc/named.conf:

options {
??????

??listen-on port 53 { any; }; ##开放端口面向所有
????????listen-on-v6 port 53 { ::1; };
????????directory???????"/var/named";
????????dump-file???????"/var/named/data/cache_dump.db";
????????statistics-file "/var/named/data/named_stats.txt";
????????memstatistics-file "/var/named/data/named_mem_stats.txt";
????????secroots-file???"/var/named/data/named.secroots";
????????recursing-file??"/var/named/data/named.recursing";
????????allow-query?????{ any; }; ##允许所有地址的请求另外一台客户端中设置dns


vim /etc/resolv.conf:
nameserver:172.25.254.137(服务器的ip)

测试: ping www.baidu.com二、dns高速缓存
服务器:
vim /etc/named.conf:

10 options {
11???????? listen-on port 53 { any; };
12???????? listen-on-v6 port 53 { ::1; };
13???????? directory?????? "/var/named";
14???????? dump-file?????? "/var/named/data/cache_dump.db";
15???????? statistics-file "/var/named/data/named_stats.txt";
16???????? memstatistics-file "/var/named/data/named_mem_stats.txt";
17???????? secroots-file?? "/var/named/data/named.secroots";
18???????? recursing-file? "/var/named/data/named.recursing";
19???????? allow-query???? { any; };
20???????? forwarders????? {114.114.114.114;};

?34???????? dnssec-validation no;

!!!!!注意文件的20行是我们需要编辑的

客户端:
vim /etc/resolv.conf:
nameserver 172.25.254.137(服务器ip)

三、正向解析(把ip转换成域名)
编辑子配置文件(正向解析):
vim /etc/named.rfc1912.zones:
zone "westos.org" IN {?????????? ##维护的域名
???????? type master;??????????? ##当前服务器主dns
???????? file "westos.org.zone"; ##指定域名记录文件
???????? allow-update { none; }; ##允许更新主机列表
};

cp -p named.localhost /var/named/westos.org.zones ##复制本地域A名记录到指定域名记录文件以及权限。

编辑域名A记录文件:
vim /var/named/westos.org.zones:

$TTL 1D
@?????? IN SOA? dns.westos.org. root.westos.org. (
??????????????????????????????????????? 0?????? ; serial
??????????????????????????????????????? 1D????? ; refresh
??????????????????????????????????????? 1H????? ; retry
??????????????????????????????????????? 1W????? ; expire
??????????????????????????????????????? 3H )??? ; minimum
??????? NS????? dns.westos.org.
dns???? A?????? 172.25.254.137 ##dns指向电脑
www???? A?????? 172.25.254.37?

systemctl restart named ##重启服务

测试:
dns指向的电脑
dig www.westos.org

四、反向解析(ip转换成域名)
编辑域名A记录文件:
vim /var/named/westos.org.zone :

$TTL 1D
@?????? IN SOA? dns.westos.org. root.westos.org. (
??????????????????????????????????????? 0?????? ; serial
??????????????????????????????????????? 1D????? ; refresh
??????????????????????????????????????? 1H????? ; retry
??????????????????????????????????????? 1W????? ; expire
??????????????????????????????????????? 3H )??? ; minimum
??????????????? NS????? dns.westos.org.
dns???????????? A?????? 172.25.254.137
www???????????? CNAME?? lee.a
lee.a?????????? A?????? 172.25.254.37
lee.a?????????? A?????? 172.25.254.137
westos.org.???? MX 1??? 172.25.254.137.


编辑反向解析域名记录文件:
vim /var/named/172.25.254.ptr
$TTL 1D

$TTL 1D
@?????? IN SOA? dns.westos.org. rname.invalid. (
??????????????????????????????????????? 0?????? ; serial
??????????????????????????????????????? 1D????? ; refresh
??????????????????????????????????????? 1H????? ; retry
??????????????????????????????????????? 1W????? ; expire
??????????????????????????????????????? 3H )??? ; minimum
??????? NS????? dns.westos.org.
dns???? A?????? 172.25.254.137
137???? PTR???? mail.westos.org.

配置子配置文件(反向解析):???????
vim /etc/named.rfc1912.zones:
zone "254.25.172.in-addr.arpa" IN {
???????? type master;
???????? file "172.25.254.ptr";
???????? allow-update { none; };
};

systemctl restart named

测试:
(dns指向电脑)
dig -x 172.25.254.137

实验五、双向解析
nmcli connection up System\ ens3
ip addr show ens3
dns主机添加一块网卡,配置新的ip:
DEVICE=ens3
ONBOOT=yes
BOOTPROTO=none
IPADDR0=172.25.254.137
PERFIX0=24
IPADDR1=1.1.1.137
PERFIX=24

虚拟机:
DEVICE=ens3
ONBOOT=yes
BOTPROTO=none
IPADDR=1.1.1.237
PERFIX=24
DNS1=1.1.1.137

??????????????? ####dns主机编辑配置文件####
vim /etc/named.conf:

zone "." IN {
???????? type hint;
???????? file "named.ca";
 };

 include "/etc/named.rfc1912.zones"
 include "/etc/named.root.key";
 */
 view localnet {
???????? match-clients{ 1.1.1.237/24; };
???????? zone "." IN {
???????????????? type hint;
???????????????? file "named.ca";
???????? };
???????? include "/etc/named.rfc1912.inter";
 };

 view anyone {
???????? match-clients{ any; };
???????? zone "." IN {
????????????????? type hint;
????????????????? file "named.ca";
???????? };
???????? include "/etc/named.rfc1912.zones";
 };


对内网文件:
vim /var/named/westos.zone:

$TTL 1D
@ IN SOA dns.westos.org. root.westos.org. (
???? 0 ; serial
???? 1D ; refresh
???? 1H ; retry
???? 1W ; expire
???? 3H ) ; minimum
? NS dns.westos.org.
dns? A 1.1.1.137
www? CNAME?? lee.a
lee.a??? A?????? 1.1.1.37
lee.a??? A?????? 1.1.1.137
westos.org.???? MX 1? 1.1.1.137.


对外网文件:
vim /var/named/westos.inter:

$TTL 1D
@?????? IN SOA? dns.westos.org. root.westos.org. (
??????????????????????????????????????? 0?????? ; serial
??????????????????????????????????????? 1D????? ; refresh
??????????????????????????????????????? 1H????? ; retry
??????????????????????????????????????? 1W????? ; expire
??????????????????????????????????????? 3H )??? ; minimum
??????????????? NS????? dns.westos.org.
dns???????????? A?????? 172.25.254.137
www???????????? CNAME?? xue.a
xue.a?????????? A?????? 172.25.254.37
xue.a?????????? A?????? 172.25.254.137
westos.org.???? MX 1??? 172.25.254.137.

cp -p /etc/named.rfc1912.zone /etc/named.rfc1912.inter
chgrp named /etc/named.rfc1912.inter

vim /etc/named.rfc1912.inter:
?zone "westos.org" IN {
? ? ? ? ? type master;
? ? ? ? ? file "westos.org.inter";

? ? ? ? ? allow-update { none; };
?};

systemctl restart named 重启服务
测试:
dns真机:dig www.westos.org
虚拟机:dig www.westos.org

六、dns集群

客户端:vim /etc/named.conf:
两个any 一个no
vim /etc/named.rfc1912.zones:
zone "westos.org" IN {
??????? type slave;
??????? masters { 172.252.54.137;};
??????? file "slaves/westos.org.zone";
};

关闭防火墙。

vim /etc/named.rfc1912.westos
nameserver 172.25.254.137

dns主机:
/named.rfc1912.inter
zone "westos.org" IN {
??????? type master;
??????? file "westos.org.zone";
??????? allow-update { none; };
??????? also-notify { 172.25.254.237; };
};

vim /etc/

增量变化:
$TTL 1D
@?????? IN SOA? dns.westos.org. root.westos.org. (
??????????????????????????????????????? (增加)?????? ; serial
??????????????????????????????????????? 1D????? ; refresh
??????????????????????????????????????? 1H????? ; retry
??????????????????????????????????????? 1W????? ; expire
??????????????????????????????????????? 3H )??? ; minimum
??????????????? NS????? dns.westos.org.
dns????????????????????A?????? 172.25.254.137
www??????????????????CNAME?? lee.a
lee.a??????????????????A?????? 172.25.254.137
lee.a?????????? ???????A?????? 172.25.254.66
westos.org.???? ??MX 1??? 172.25.254.137.

实验七、dns的更新注意:域名解析、文件编译,不要手残

dns基于ip地址的更新:
在dns中设定:
vim /etc/named.rfc1912.zones

zone "westos.com" IN {
??????? type master;
??????? file "westos.com.zone";
??????? allow-update { 172.25.254.137; };? ##允许指定客户端更新westos域
??????? also-notify { 172.25.254.237; };

};
测试:
在1172.25.254.237
[root@rhel7_node1 ~]# nsupdate
> server 172.25.254.237
> update add hello.westos.org 86400 A 172.25.254.137 ##新曾A记录
> send
> update delete hello.westos.com?? ##删除A记录
> send?

dns基于key更新的方式:
dnssec-keygen -a HMAC-SHA256 -b 128 -n HOST westos
cp -p /etc/rndc.key /etc/westos.key
vim /etc/westos.key
key "westos" {
algorithm hmac-sha256;
secret "SB1tQcLaWeroU9lGW21zeA=="; ##注意钥匙生成的是什么就用什么
};

vim /etc/named.conf
43 include "/etc/wesots.key";
vim /etc/named.rfc1912.zones
zone "westos.com" IN {
??????? type master;
??????? file "westos.org.zone";
??????? allow-update { key westos; };
?????? also-notify { 172.25.254.237; }; ##被通知的主机ip
};

systemctl restart named?

[root@rhel7_node1 ~]# nsupdate -k /mnt/Kwestos.+163+26695.private
> server 192.168.0.20
> update add hello.westos.org 86400 A 172.25.254.137
> send
> quitdnf instsall dhcp-server -y
vim /etc/dhcpd/dhcpd.conf

# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#

# option definitions common to all supported networks...
option domain-name "westos.org";
option domain-name-servers 172.25.254.137;

default-lease-time 600;
max-lease-time 7200;

# Use this to enble / disable dynamic dns updates globally.
ddns-update-style interim;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.

# This is a very basic subnet declaration.

subnet 172.25.254.137 netmask 255.255.255.0 {
? range 172.25.254.70 172.25.254.90;
? option routers 172.25.254.137;

}

key westos {
???????? algorithm hmac-sha256;
???????? secret SB1tQcLaWeroU9lGW21zeA==;
?????? };

zone westos.org. {
primary 172.25.254.137;
key westos;
}

dns的key更新

测试:

设定测试主机网络工作方式为dhcp
设定主机名称test.westos.com

重启网络

dig test.westos.com

可以得到正确解析

  系统运维 最新文章
配置小型公司网络WLAN基本业务(AC通过三层
如何在交付运维过程中建立风险底线意识,提
快速传输大文件,怎么通过网络传大文件给对
从游戏服务端角度分析移动同步(状态同步)
MySQL使用MyCat实现分库分表
如何用DWDM射频光纤技术实现200公里外的站点
国内顺畅下载k8s.gcr.io的镜像
自动化测试appium
ctfshow ssrf
Linux操作系统学习之实用指令(Centos7/8均
上一篇文章      下一篇文章      查看所有文章
加:2021-08-08 11:55:18  更:2021-08-08 11:56:12 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/25 19:21:03-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码