当前位置: 首页 > article >正文

Linux案例:DNS服务器配置

Linux案例:DNS服务器配置

实验一:正向解析

服务端配置:

[root@server ~]# setenforce 0
[root@server ~]# nmcli c modify ens160 ipv4.method manual ipv4.addresses 192.168.70.131/24 ipv4.gateway 192.168.70.2 ipv4.dns 114.114.114.114
[root@server ~]# nmcli  c reload 
[root@server ~]# nmcli c u ens160
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/3)
[root@server ~]# vim /etc/named.conf 
[root@server ~]# vim /etc/named.rfc1912.zones 
[root@server ~]# cd /var/named
[root@server named]# ls
192.168.70.arpa  data  dynamic  named.ca  named.empty  named.localhost  named.loopback  named.openlab.com  openlab.com.zone  slaves
[root@server named]# cp -a named.localhost openlab.com.zone 
cp:是否覆盖'openlab.com.zone'? 
[root@server named]# vim openlab.com.zone 
[root@server named]# systemctl restart named

客户端配置

[root@cilent ~]# setenforce 0   
[root@cilent ~]# nmcli c modify ens160 ipv4.method manual ipv4.addresses 192.168.70.132/24 ipv4.gateway 192.168.70.2 ipv4.dns 114.114.114.114
[root@cilent ~]# nmcli c reload 
[root@cilent ~]# nmcli c u ens160
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
[root@cilent ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens160 
[root@cilent ~]# nmcli c reload 
[root@cilent ~]# nmcli c u ens160 
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
[root@cilent ~]# nslookup www.openlab.com
Server:		192.168.70.131
Address:	192.168.70.131#53

Name:	www.openlab.com
Address: 192.168.70.131

[root@cilent ~]# 
[root@cilent ~]# nslookup 
> bbs.openlab.com
Server:		192.168.70.131
Address:	192.168.70.131#53

Name:	bbs.openlab.com
Address: 192.168.70.131
> 
[root@cilent ~]# dig www.openlab.com

; <<>> DiG 9.16.23-RH <<>> www.openlab.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 14614
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: 7a5edfca7630180d010000006725a90878cd979838ac7c70 (good)
;; QUESTION SECTION:
;www.openlab.com.		IN	A

;; ANSWER SECTION:
www.openlab.com.	86400	IN	A	192.168.70.131

;; Query time: 3 msec
;; SERVER: 192.168.70.131#53(192.168.70.131)
;; WHEN: Sat Nov 02 12:22:30 CST 2024
;; MSG SIZE  rcvd: 88

实验二:反向解析

服务端配置

[root@server ~]# nmcli  c  modify  ens160   ipv4.method manual ipv4.addresses  192.168.48.130/24  ipv4.gateway  192.168.48.2  ipv4.dns  114.114.114.114
[root@server ~]# nmcli  c  reload 
[root@server ~]# nmcli  c  up  ens160
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/2)
[root@server ~]# vim  /etc/named.conf 
# 需改2行
       listen-on port 53 { any; };  # any为允许所有主机
       
        allow-query     { 192.168.48.131; };  # 此处也可以写为IP地址 
[root@server ~]# vim /etc/named.conf 
[root@server ~]# vim /etc/named.rfc1912.zones 
[root@server ~]# cd /var/named
[root@server named]# ls
192.168.70.arpa  data  dynamic  named.ca  named.empty  named.localhost  named.loopback  named.openlab.com  openlab.com.zone  slaves
[root@server named]# cp -a named.localhost openlab.com.zone 
cp:是否覆盖'openlab.com.zone'? 
[root@server named]# vim openlab.com.zone 
[root@server named]# systemctl restart named
[root@server named]# vim /etc/named.conf
[root@server named]# vim /etc/named.rfc1912.zones 
[root@server named]# ls
192.168.70.arpa  data  dynamic  named.ca  named.empty  named.localhost  named.loopback  named.openlab.com  openlab.com.zone  slaves
[root@server named]# cp -a named.loopback 192.168.70.arpa 
cp:是否覆盖'192.168.70.arpa'? 
[root@server named]# vim 192.168.70.arpa 
[root@server named]# systemctl restart named

客户端配置

[root@cilent ~]# nmcli c modify ens160  ipv4.method manual ipv4.addresses 192.168.48.131/24 ipv4.gateway 192.168.48.2 ipv4.dns 192.168.48.130  # 注意,此处dns改为服务端的IP地址,后续就不用再单独修改
[root@cilent ~]# nmcli  c  reload 
[root@cilent ~]# nmcli  c  up  ens160
[root@cilent ~]# nslookup 192.168.70.131
131.70.168.192.in-addr.arpa	name = www.openlab.com.
131.70.168.192.in-addr.arpa	name = ftp.openlab.com.
131.70.168.192.in-addr.arpa	name = ns.openlab.com.

实验三:主从DNS服务器

主服务端

[root@server named]# nmcli c modify ens160 ipv4.method manual ipv4.addresses 192.168.70.131/24 ipv4.gateway 192.168.70.2 ipv4.dns 192.168.70.131
[root@server named]# nmcli c reload 
[root@server named]# nmcli c u ens160 
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/4)
[root@server named]# vim /etc/named.conf
[root@server named]# vim /etc/named.rfc1912.zones 
[root@server named]# ls
192.168.70.arpa  data  dynamic  named.ca  named.empty  named.localhost  named.loopback  named.openlab.com  openlab.com.zone  slaves
[root@server named]# cp -a named.localhost openlab.com.zone 
cp:是否覆盖'openlab.com.zone'? 
[root@server named]# vim openlab.com.zone 
[root@server named]# cp -a named.loopback 192.168.70.arpa 
cp:是否覆盖'192.168.70.arpa'? 
[root@server named]# vim 192.168.70.arpa 
[root@server named]# systemctl restart named

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

从服务端

[root@cilent ~]# vim /etc/named.conf
[root@cilent ~]# vim /etc/named.rfc1912.zones 
[root@cilent ~]# cd /var/named/slaves/
[root@cilent slaves]# ls
openlab.com.zone
[root@cilent slaves]# systemctl start named
[root@cilent slaves]# ls
192.168.70.arpa  openlab.com.zone
[root@cilent slaves]# nslookup www.openlab.com
Server:		192.168.70.131
Address:	192.168.70.131#53

Name:	www.openlab.com
Address: 192.168.70.131

[root@cilent slaves]# nslookup 192.168.70.131
131.70.168.192.in-addr.arpa	name = ftp.openlab.com.
131.70.168.192.in-addr.arpa	name = bbs.openlab.com.
131.70.168.192.in-addr.arpa	name = ns.openlab.com.
131.70.168.192.in-addr.arpa	name = www.openlab.com.

[root@cilent slaves]# dig @192.168.70.131 www.openlab.com

; <<>> DiG 9.16.23-RH <<>> @192.168.70.131 www.openlab.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47991
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: bfa413a2fb854884010000006725b78df48699372a4e885e (good)
;; QUESTION SECTION:
;www.openlab.com.		IN	A

;; ANSWER SECTION:
www.openlab.com.	86400	IN	A	192.168.70.131

;; Query time: 4 msec
;; SERVER: 192.168.70.131#53(192.168.70.131)
;; WHEN: Sat Nov 02 13:24:27 CST 2024
;; MSG SIZE  rcvd: 88

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述


http://www.kler.cn/a/382439.html

相关文章:

  • “单元测试”应该怎么写比较好
  • 【dvwa靶场:XSS系列】XSS (Stored)低-中-高级别,通关啦
  • stack和queue --->容器适配器
  • Node.js——fs模块-同步与异步
  • Unity中实现伤害飘字或者提示飘字效果(DoTween实现版本)
  • Git使用指南
  • java、excel表格合并、指定单元格查找、合并文件夹
  • HTML字符实体详解
  • 尚庭公寓-小程序接口
  • 【51蛋骗鸡16路电子开关编程CD4067使用switch】2021-12-27
  • Maven(17)如何使用Maven生成项目的文档?
  • 什么时候出现线程安全,如何实现线程安全?
  • ubuntu交叉编译expat库给arm平台使用
  • 【蓝队技能】【溯源反制】反打红队-蜜罐工具反制
  • MySQL数据库中的视图
  • 多模态模型中的动态分辨率总结
  • 前端使用PDF.js把返回的base64或二进制文件流格式,实现pdf文件预览
  • 移门减震器-止门时的震动保护门体和墙体
  • 详细分析SQL state [99999]; error code [17059]; 无法转换为内部表示 解决方法(实战讲解)
  • 【LeetCode】【算法】322. 零钱兑换
  • sqli-labs(第一关)
  • 5G学习笔记三之物理层、数据链路层、RRC层协议
  • Flinksql 模拟 视图 监听
  • Python(PySimpleGUI 库)
  • gulp入门教程16:gulp插件gulp-uglify
  • 软件测试学习笔记丨Flask操作数据库-一对多