1.准备工作
# 服务端及客户端都关闭安全软件
[root@node ~]# setenforce 0
setenforce: SELinux is disabled
[root@node ~]# systemctl stop firewalld
# 服务端安装bind软件
[root@node ~]# yum install bind -y
# 服务端安装bind软件
[root@node ~]# nmcli c modify ens32 ipv4.method manual ipv4.addresses 192.168.205.137/24 ipv4.gateway 192.168.205.2 ipv4.dns 114.114.114.114
[root@Server ~]# nmcli c reload
[root@Server ~]# nmcli c up ens32
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/3)
# 客户端设置静态IP
[root@node ~]# nmcli c modify ens32 ipv4.method manual ipv4.addresses 192.168.205.138/24 ipv4.gateway 192.168.205.2 ipv4.dns 114.114.114.114
[root@node ~]# nmcli c reload
[root@node ~]# nmcli c up ens32
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/3)
2.DNS配置
第一步:服务端操作,编辑bind主配置文件
[root@server ~]# vim /etc/named.conf
# 需改2行
listen-on port 53 { any; }; # any为允许所有主机
allow-query { any; };
第二步:服务端操作,编辑区域配置文件,可以选择一个模版修改局部(推荐),也可以全部清空重启写入数据
[root@server ~]# vim /etc/named.rfc1912.zones
zone "openlab.com" IN { # 双引号中输入,表示管理那个区域
type master;
file "openlab.com.zone"; # 双引号中输入,表示数据配置文件的名称,注意:不写路径
allow-update { none; };
};
第三步:服务端操作,编辑数据配置文件,使用拷贝命令将模版文件(/var/named/named.localhost)复制一份在修改局部,注意:拷贝时需要加-a参数,即拷贝内容及文件属性保证文件内容一致、权限等信息不变
[root@Server ~]# cd /var/named
[root@Server named]# ls
data dynamic named.ca named.empty named.localhost named.loopback slaves
[root@Server named]# cp -a named.localhost openlab,com,zone
[root@Server named]# vim openlab.com.zone
$TTL 1D
openlab.com. IN SOA ns.opeblab.com. admin.openlab.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
openlab.com. IN NS ns.openlab.com.
ns.openlab.com. IN A 192.168.205.137
www.openlab.com. IN A 192.168.205.137
ftp.openlab.com. IN A 192.168.205.137
bbs.openlab.com. IN A 192.168.205.137
www1.openlab.com. IN CNAME www.openlab.com.
第四步:服务端重启服务
[root@Server named]# systemctl restart named
3.测试
定义客户端,将客户端的dns修改为服务端的IP地址
# 编辑客户端网卡配置文件
[root@node1 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens32
dns=192.168.48.130; # dns改为服务端的IP地址
[root@node ~]# nmcli c reload
[root@node ~]# nmcli c up ens32
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/4)
# 定位客户端测试
[root@node ~]# nslookup www.openlab.com
Server: 192.168.205.137
Address: 192.168.205.137#53
Name: www.openlab.com
Address: 192.168.205.137
[root@node ~]# nslookup # 进入交互模式
> bbs.openlab.com
Server: 192.168.205.137
Address: 192.168.205.137#53
Name: bbs.openlab.com
Address: 192.168.205.137
> # ctrl+d退出
[root@node ~]# dig www.openlab.com
; <<>> DiG 9.16.23 <<>> www.openlab.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48463
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: ff4e9869598fb20a0100000065ec0536ad9ca488cffd368c (good)
;; QUESTION SECTION:
;www.openlab.com. IN A
;; ANSWER SECTION:
www.openlab.com. 86400 IN A 192.168.205.137
;; Query time: 2 msec
;; SERVER: 192.168.205.137#53(192.168.205.137)
;; WHEN: Sat Mar 09 17:42:29 CST 2024
;; MSG SIZE rcvd: 88
[root@node ~]# nslookup www1.openlab.com
Server: 192.168.205.137
Address: 192.168.205.137#53
www1.openlab.com canonical name = www.openlab.com.
Name: www.openlab.com
Address: 192.168.205.137
二、反向解析
服务端IP 客户端IP 网址
192.168.205.137 192.168.205.138 www.openlab.com
1.准备工作
# 服务端及客户端都关闭安全软件
[root@Server ~]# setenforce 0
setenforce: SELinux is disabled
[root@Server ~]# systemctl stop firewalld
# 服务端安装bind软件
[root@Server ~]# yum install bind -y
# 服务端配置静态IP
[root@Server ~]# nmcli c modify ens32 ipv4.method manual ipv4.addresses 192.168.205.137/24 ipv4.gateway 192.168.205.2 ipv4.dns 114.114.114.114
[root@Server ~]# nmcli c reload
[root@Server ~]# nmcli c up ens32
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/3)
# 客户端设置静态IP
[root@Server ~]# nmcli c modify ens32 ipv4.method manual ipv4.addresses 192.168.205.137/24 ipv4.gateway 192.168.205.2 ipv4.dns 192.168.205.137 # 注意,此处dns改为服务端的IP地址,后续就不用再单独修改
[root@Server ~]# nmcli c reload
[root@Server ~]# nmcli c up ens32
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/4)
2.DNS设置
第一步:服务端操作,编辑主配置文件
[root@Server ~]# vim /etc/named.conf
options {
listen-on port 53 { any; }; # 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 { 192.168.205.138; };
第二步:服务端操作,编辑区域配置文件,添加反向解析记录,注意:区域名称中IP地址反向书写,只需书写网段号
[root@server named]# vim /etc/named.rfc1912.zones
zone "205.168.192.in-addr.arpa" IN {
type master;
file "192.168.205.arpa";
allow-update { none; };
};
第三步:服务端操作,编辑数据配置文件,复制一份反向解析模版(/var/named/named.loopback),复制时需要加-a 参数,在修改局部即可
[root@Server ~]# cd /var/named
[root@Server named]# ls
data dynamic named.ca named.empty named.localhost named.loopback slaves
[root@Server named]# cp -a named.loopback 192.168.205.arpa
[root@Server named]# vim 192.168.205.arpa
$TTL 1D
@ IN SOA ns.openlab.com. jenny.qq.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS ns.openlab.com.
ns.openlab.com. IN A 192.168.48.130
130 IN PTR ns.openlab.com.
130 IN PTR www.openlab.com.
130 IN PTR ftp.openlab.com.
第四步:重启服务
[root@Server named]# systemctl restart named
3.客户端测试
[root@node1 ~]# nslookup 192.168.205.137
130.48.168.192.in-addr.arpa name = www.openlab.com.
130.48.168.192.in-addr.arpa name = ftp.openlab.com.
130.48.168.192.in-addr.arpa name = ns.openlab.com.
————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/2201_75642447/article/details/137697850
上一篇:五个挂!aapoker到底有挂,德扑ai自定义设置数据,详细教程(2025已更新)-哔哩哔哩
下一篇:docker 在hub服务器上登录时提示 error storing credentials 、启动使用gpu的容器 等问题解决方法