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

RHCE综合实验

任务需求:客户端通过访问 www.nihao.com 后,能够通过 dns 域名解析,访问到 nginx 服务中由 nfs 共享的首页文件,内容为:Very good, you have successfully set up the system. 各个主机能够实现时间同步,并且都开启防火墙来保证服务安装。

作用系统IP主机名软件
web 服务器redhat9.5192.168.121.8webnginx,nfs-utils
nfs 服务器redhat9.5192.168.121.9nfsnfs-utils
DNS 主服务器redhat9.5192.168.121.18dns1bind
DNS 从服务器redhat9.5192.168.121.28dns2bind
客户端redhat9.5192.168.121.7clientbind-utils

1.环境准备

web

[root@localhost ~]# hostnamectl hostname web
[root@localhost ~]# nmcli c modify ens160 ipv4.method manual ipv4.addresses 192.168.121.8/24 ipv4.gateway 192.168.121.2 ipv4.dns 223.5.5.5 connection.autoconnect yes
[root@localhost ~]# nmcli c up ens160

nfs

[root@localhost ~]# hostnamectl hostname nfs
[root@localhost ~]# nmcli c modify ens160 ipv4.method manual ipv4.addresses 192.168.121.9/24 ipv4.gateway 192.168.121.2 ipv4.dns 223.5.5.5 connection.autoconnect yes
[root@localhost ~]# nmcli c up ens160

dns1

[root@localhost ~]# hostnamectl hostname dns1
[root@localhost ~]# nmcli c modify ens160 ipv4.method manual ipv4.addresses 192.168.121.18/24 ipv4.gateway 192.168.121.2 ipv4.dns 223.5.5.5 connection.autoconnect yes
[root@localhost ~]# nmcli c up ens160

dns2

[root@localhost ~]# hostnamectl hostname dns2
[root@localhost ~]# nmcli c modify ens160 ipv4.method manual ipv4.addresses 192.168.121.28/24 ipv4.gateway 192.168.121.2 ipv4.dns 223.5.5.5 connection.autoconnect yes
[root@localhost ~]# nmcli c up ens160

client

[root@localhost ~]# hostnamectl hostname client
[root@localhost ~]# nmcli c modify ens160 ipv4.method manual ipv4.addresses 192.168.121.7/24 ipv4.gateway 192.168.121.2 ipv4.dns "192.168.121.18 192.168.121.28" connection.autoconnect yes
[root@localhost ~]# nmcli c up ens160

关闭几台服务器的selinux:

sed -i 's/SELINUX=enforcing/SELINUX=Permissive/g' /etc/selinux/config
 setenforce 0

2.时间同步

安装chrony

dnf install chrony -y

启动并设置开机自启动
systemctl start chronyd
systemctl enable chronyd
 

3.NFS服务器配置

3.1安装NFS服务(192.168.121.9,主机名:nfs)

[root@nfs ~]# dnf install nfs-utils -y

3.2创建共享文件夹并设置权限

[root@nfs ~]# mkdir /nfs/data -p
[root@nfs ~]# cat > /etc/exports <<EOF
> /nfs/data 192.168.121.0/24(rw,sync)
> EOF

3.3创建首页文件

[root@nfs ~]# echo Very good, you have successfully set up the system. > /nfs/data/index.html

3.4启动NFS服务并放开防火墙端口 

[root@nfs ~]# systemctl start nfs-server
[root@nfs ~]# systemctl enabel nfs-server

[root@nfs ~]# firewall-cmd --permanent --add-service=nfs
[root@nfs ~]# firewall-cmd --reload

4.Web服务器配置 (192.168.121.8,主机名:web)

4.1安装nginx和NFS客户端

[root@web ~]# dnf install nginx -y
[root@web ~]# dnf install nfs-utils -y

4.2挂载NFS共享

[root@web ~]# mkdir -p /usr/share/nginx/html
[root@web ~]# mount 192.168.121.9:/nfs/data /usr/share/nginx/html

4.3配置nginx 

[root@web ~]# cat /etc/nginx/nginx.conf

    server {
        listen       80;
        listen       [::]:80;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        error_page 404 /404.html;
        location = /404.html {
        }

4.4启动nginx并开放防火墙端口

[root@web ~]# systemctl start nginx
[root@web ~]# systemctl enable nginx
[root@web ~]# firewall-cmd --permanent --add-serverice=http
[root@web ~]# firewall-cmd --reload

5.DNS主服务器配置(192.168.121.18,主机名:dns1) 

5.1安装bind

[root@dns1 ~]# dnf install bind -y

5.2配置主配置文件

[root@dns1 ~]# vi /etc/named.conf 

options {
        listen-on port 53 { 192.168.121.18; };
        directory       "/var/named";
};

zone "nihao.com" IN{
        type master;
        file "nihao.com";
}

5.3创建区域文件 

[root@dns1 ~]# vi /var/named/nihao.com 

$TTL    1D
@       IN      SOA     @       admin.nihao.com.(
                                                0
                                                1D
                                                2H
                                                3W
                                                2D
                                                )
@       IN      NS      dns1.nihao.com.
@       IN      NS      dns2.nihao.com.
www     IN      A       192.168.121.8

5.4启动bind并放通防火墙端口

[root@dns1 ~]# systemctl start named
[root@dns1 ~]# systemctl enable named
[root@dns1 ~]# firewall-cmd --permanent --add-service=dns
[root@dns1 ~]# firewall-cmd --reload

6 DNS从服务器配置(192.168.121.28,主机名:dns2)

6.1安装Bind

[root@dns2~]# dnf install bind -y

6.2配置主配置文件

[root@dns2 ~]# vi /etc/named.conf 

options {
        listen-on port 53 { 192.168.121.28; };
        directory       "/var/named";
};

zone "nihao.com" IN{
        type slave;
        file "slaves/nihao.com";

        master {192.168.121.28; };
}

6.3启动Bind并开放防火墙端口

[root@dns2 ~]# systemctl start named
[root@dns2 ~]# systemctl enable named
[root@dns2 ~]# firewall-cmd --permanent --add-service=dns
[root@dns2 ~]# firewall-cmd --reload

7.客户端配置(192.168.121.7,主机名:client) 

7.1安装bind工具

[root@client~]# dnf install bind -y

7.2查看DNS

[root@client ~]# cat /etc/resolv.conf 
# Generated by NetworkManager
nameserver 192.168.121.18
nameserver 192.168.121.28

7.3测试访问

[root@client ~]# curl http://www.nihao.com
Very good, you have successfully set up the system.

配置完成

 

相关文章:

  • LS-NET-004-简单二层环路解决(华为锐捷思科)
  • kotlin @JvmStatic的使用
  • 【C++】STL(1) - 序列容器
  • 在C#的MVC框架framework项目的使用ajax,及源码下载
  • 织梦DedeCMS后台发布文章增加“顶”和“踩”默认随机值,并可后台修改
  • [Windows] OfficeAI 助手 v0.3.20(长期免费,本地支持WPS/Word联动)
  • Java多线程与高并发专题——在 Thread 中多个 ThreadLocal 是怎么存储的?
  • langgraph简单Demo(使用langserve实现外部调用)
  • 解码软件需求的三个维度:从满足基础到创造惊喜
  • UMA架构下的GPU 显存
  • 4、MySQL的存储引擎有哪些?【中高频】
  • 蓝桥杯篇---按键长按与双击
  • 机试准备最后一天
  • electron框架(1.0)认识electron和基础创建
  • Elasticsearch基础教程:从入门到上手
  • 大话数据结构第二章,算法笔记
  • Oracle 公布 Java 的五大新功能
  • Vue安装及首次运行报错的相关问题解决方案
  • 二叉树(堆)
  • CentOS系统下安装tesseract-ocr5.x版本
  • 【社论】公平有序竞争,外卖行业才能多赢
  • 四部门:到2025年底,全国行政村5G通达率超过90%
  • “救护车”半路加价?陕西卫健委已介入,记者调查:黑救护车挤占市场
  • 李公明谈“全球南方”与美术馆
  • 美股全线收涨:道指涨逾千点,纳斯达克中国金龙指数涨5.4%
  • 张笑宇:物质极大丰富之后,我们该怎么办?