码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • Linux之DNS解析和主从配置及selinux使用超详解


    目录

    1.DNS的解析流程

    ​2.DNS主从配置: 需要两台机器: 一台为主dns服务器,一台为从DNS服务器

    1.在主服务器的主配置文件中添加从服务器

    添加allow-transfer 

    2.从服务器中下载bind软件

     3.从服务器进入主配置文件配置

    4.在下面添加dns配置文件zone,最后两个为已知文件 

    5. 在辅助配置文件中添加 

    6.主服务器和从服务器重启服务

    3.使用httpd服务演示安全上下文值的设定(selinux)

     1.下载selinux使用环境所需的软件

     2.打开防火墙允许给http添加服务,查看selinux状态

      3.访问网站发现是服务器的测试界面​

    4.修改自定义目录的安全上下文的值:

     5.然后访问网站​

    4.使用web服务端口的改变来演示端口的设定(selinux)

     1.创建目录

     2.主配置文件

     3.重启httpd服务报错​

     4.查看网页显示文件的安全上下文​

     5.在防火墙添加8888端口并修改安全上下文


    1.DNS的解析流程


    2.DNS主从配置: 需要两台机器: 一台为主dns服务器,一台为从DNS服务器

     主服务器为192.168.40.129/从服务器为192.168.40.131

    1.在主服务器的主配置文件中添加从服务器

    [root@rhcsa ~]# vim /etc/named.conf

    添加allow-transfer 

    2.从服务器中下载bind软件

    1. [root@rhce ~]# yum install bind -y
    2. Updating Subscription Management repositories.
    3. Unable to read consumer identity
    4. This system is not registered with an entitlement server. You can use subscription-manager to register.
    5. Repository AppStream is listed more than once in the configuration
    6. Last metadata expiration check: 1:41:17 ago on Sat 30 Jul 2022 12:30:24 PM CST.
    7. Dependencies resolved.
    8. ================================================================================
    9. Package Architecture Version Repository Size
    10. ================================================================================
    11. Installing:
    12. bind x86_64 32:9.11.26-6.el8 AppStream 2.1 M
    13. Transaction Summary
    14. ================================================================================
    15. Install 1 Package
    16. Total download size: 2.1 M
    17. Installed size: 4.5 M
    18. Downloading Packages:
    19. bind-9.11.26-6.el8.x86_64.rpm 237 kB/s | 2.1 MB 00:09
    20. --------------------------------------------------------------------------------
    21. Total 237 kB/s | 2.1 MB 00:09
    22. Running transaction check
    23. Transaction check succeeded.
    24. Running transaction test
    25. Transaction test succeeded.
    26. Running transaction
    27. Preparing : 1/1
    28. Running scriptlet: bind-32:9.11.26-6.el8.x86_64 1/1
    29. Installing : bind-32:9.11.26-6.el8.x86_64 1/1
    30. Running scriptlet: bind-32:9.11.26-6.el8.x86_64 1/1
    31. [/usr/lib/tmpfiles.d/pesign.conf:1] Line references path below legacy directory /var/run/, updating /var/run/pesign → /run/pesign; please update the tmpfiles.d/ drop-in file accordingly.
    32. Verifying : bind-32:9.11.26-6.el8.x86_64 1/1
    33. Installed products updated.
    34. Installed:
    35. bind-32:9.11.26-6.el8.x86_64
    36. Complete!

     3.从服务器进入主配置文件配置

    [root@rhce ~]# vim /etc/named.conf

    4.在下面添加dns配置文件zone,最后两个为已知文件 

    5. 在辅助配置文件中添加

    [root@rhcsa ~]# vim /var/named/40.168.192.zone 

    [root@rhcsa ~]# vim /var/named/openlab.zone

     

    6.主服务器和从服务器重启服务

    1. [root@rhcsa ~]# systemctl restart named
    2. [root@rhce slaves]# systemctl restart named

    3.使用httpd服务演示安全上下文值的设定(selinux)

     1.下载selinux使用环境所需的软件

    1. [root@rhce ~]# yum install setools-console -y
    2. Updating Subscription Management repositories.
    3. Unable to read consumer identity
    4. This system is not registered with an entitlement server. You can use subscription-manager to register.
    5. Repository AppStream is listed more than once in the configuration
    6. Last metadata expiration check: 3:18:22 ago on Sat 30 Jul 2022 12:30:24 PM CST.
    7. Dependencies resolved.
    8. ================================================================================
    9. Package Architecture Version Repository Size
    10. ================================================================================
    11. Installing:
    12. setools-console x86_64 4.3.0-2.el8 base 42 k
    13. Transaction Summary
    14. ================================================================================
    15. Install 1 Package
    16. Total download size: 42 k
    17. Installed size: 122 k
    18. Downloading Packages:
    19. setools-console-4.3.0-2.el8.x86_64.rpm 6.7 kB/s | 42 kB 00:06
    20. --------------------------------------------------------------------------------
    21. Total 6.7 kB/s | 42 kB 00:06
    22. Running transaction check
    23. Transaction check succeeded.
    24. Running transaction test
    25. Transaction test succeeded.
    26. Running transaction
    27. Preparing : 1/1
    28. Installing : setools-console-4.3.0-2.el8.x86_64 1/1
    29. Running scriptlet: setools-console-4.3.0-2.el8.x86_64 1/1
    30. Verifying : setools-console-4.3.0-2.el8.x86_64 1/1
    31. Installed products updated.
    32. Installed:
    33. setools-console-4.3.0-2.el8.x86_64
    34. Complete!

     2.打开防火墙允许给http添加服务,查看selinux状态

    1. [root@rhcsa ~]# systemctl restart firewalld
    2. [root@rhcsa ~]# firewall-cmd --permanent --add-service=http
    3. success
    4. [root@rhcsa ~]# firewall-cmd --reload
    5. success
    6. [root@rhcsa ~]# setenforce 1
    7. [root@rhcsa ~]# getenforce
    8. Enforcing
    9. [root@rhcsa ~]# vim /etc/httpd/conf.d/myhosts.conf
    10. [root@rhcsa ~]# mkdir -pv /www/80
    11. mkdir: created directory '/www/80'
    12. [root@rhcsa ~]# echo this is 80 > /www/80/index.html
    13. [root@rhcsa ~]# systemctl restart httpd

      3.访问网站发现是服务器的测试界面

    4.修改自定义目录的安全上下文的值:

    1. [root@rhcsa 80]# chcon -t httpd_sys_content_t /www/ -R
    2. [root@rhcsa 80]# ls -Z
    3. system_u:object_r:httpd_sys_content_t:s0 index.html

     5.然后访问网站


    4.使用web服务端口的改变来演示端口的设定(selinux)

     1.创建目录

    1. [root@rhcsa ~]# mkdir /www/8888
    2. [root@rhcsa ~]# echo this is 8888 > /www/8888/index.html

     2.编辑主配置文件

    [root@rhcsa ~]# vim /etc/httpd/conf.d/myhosts.conf 
    

     3.重启httpd服务报错

     4.查看网页显示文件的安全上下文

     5.在防火墙添加8888端口并修改安全上下文

    1. [root@rhcsa 8888]# firewall-cmd --permanent --add-port=8888/tcp
    2. success
    3. [root@rhcsa 8888]# firewall-cmd --reload
    4. success
    5. [root@rhcsa 8888]# semanage port -a -t http_port_t -p tcp 8888
    6. [root@rhcsa 8888]# systemctl restart httpd

  • 相关阅读:
    数据结构与算法课后题-第二章(顺序表)
    【C++】C/C++内存管理
    泵站物联网实现远程监控,为泵站管理带来哪些好处?
    background-repeat
    直接卖断货了!百元价位现象级蓝牙耳机西圣AVA2究竟有什么亮点
    浮点数通信
    如何理解低位交叉编址的公式T+(m-1)r
    有向图计数优化版原理及C++实现
    英特尔OneAPI介绍
    7.网络原理之TCP_IP(下)
  • 原文地址:https://blog.csdn.net/weixin_64051859/article/details/126074599
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号