RHCE综合实验

一、实验内容:(附加条件:防火墙、SELinux  开启状态)

二、实验步骤:

        将IP为192.168.36.130设置为dns主、IP为192.168.36.132设置为dns从、在dns主中创建dadou、xiaodou、doudou三个web,在dns从中加一个192.168.36.133的IP,且监听端口设为3031、3032、3033,最后打开防火墙、SELinux,放行端口进行测试。

//主
vim /etc/httpd/conf.d/vhost.conf
vim /etc/named/named.conf
cd /www
mkdir /dadou
ll
mkdir dadou
ll
mkdir xiaodou
mkdir doudou
echo This is dadou > /www/dadou/index.html
echo This is xiaodou > /www/xiaodou/index.html
echo This is doudou > /www/doudou/index.html
vim /etc/hosts
cd /etc/httpd/conf.d
curl www.dadou.com
curl www.xiaodou.com
curl www.doudou.com
ll
vim vhost.conf 
systemctl restart httpd
curl www.doudou.com
vim /etc/named.conf
systemctl restart httpd
cd /etc/named/
ll
cd /var/named/
ll
vim named.dadou
vim named.xiaodou
vim named.doudou
systemctl restart httpd
dig -t A baidu.com
vim /named
vim /etc/named.conf
systemctl restart httpd
cd
vim /etc/httpd/conf.d/vhost.conf
systemctl stop firewalld
setenforce 0
systemctl restart httpd
systemctl restart named
systemctl start firewalld
firewall-cmd --add-service=http --permanent 
firewall-cmd --add-service=dns --permanent 
firewall-cmd --add-port=3031 --permanent 
firewall-cmd --add-port=3031/tcp --permanent 
firewall-cmd --add-port=3032/tcp --permanent 
firewall-cmd --add-port=3033/tcp --permanent 
firewall-cmd --reload
setenforce 1
semanage port -a -t http_port_t -p tcp 3031
semanage port -a -t http_port_t -p tcp 3032
semanage port -a -t http_port_t -p tcp 3033
chcon -t httpd_sys_content_t /www/ -R


//从  客户端
vim /etc/named.conf
    2  cd /etc/yum.repos.d/
    3  vim rpm.repo
    4  mount /dev/sr0 /mnt
    5  cd
    6  dnf install bash-com* net-tools lrz* vim -y
    7  nmcli connection modify ens160 ipv4.dns 192.168.36.130
    8  nmcli connection modify ens160 ipv4.method manual
    9  nmcli connection modify ens160 connection.autoconect yes
   10  nmcli connection modify ens160 connection.autoconnect yes
   11  nmcli connection up ens160
   12  systemctl restart httpd
   13  systemctl restart named
   14  dnf install http -y
   15  dnf install httpd -y
   16  systemctl restart httpd
   17  dnf install named -y
   18  dnf install name -y
   19  dnf install bind -y
   20  vim /etc/named.conf
   21  cd /var/named
   22  ll
   23  vim named.zhangsan
   24  vim named.lisi
   25  vim named.zhangsan
   26  systemctl restart httpd
   27  cd
   28  systemctl restart httpd
   29  systemctl restart named
   30  cd /var/named
   31  vim named.lisi
   32  vim named.zhangsan
   33  systemctl restart named
   34  vim /etc/named.conf
   35  systemctl restart named
   36  systemctl status named.service
   37  vim /etc/named.conf
   38  systemctl restart named
   39  curl -k https://www.zhangsan.com
   40  vim /etc/named.conf
   41  vim named.zhangsan
   42  nmcli device show | grep DNS
   43  curl www.lisi.com
   44  cd
   45  vim named.conf
   46  vim /etc/named.conf
   47  systemctl restart named
   48  ll /var/named/slaves/
   49  vim /etc/named.conf
   50  vim /var/named/named.zhangsan
   51  vim /var/named/named.lisi
   52  ll /var/named/slaves/
   53  cd /var/named
   54  ll
   55  vim /etc/named/named.lisi
   56  vim /var/named/named.lisi
   57  mv named.zhangsan /var/named/slaves/
   58  ll /var/named/slaves/
   59  mv named.lisi /var/named/slaves/
   60  ll /var/named/slaves/
   61  systemctl restart named
   62  curl www.lisi.com
   63  vim /etc/httpd/named.conf
   64  vim /etc/httpd/named/named.conf
   65  vim /etc/named.conf
   66  vim /var/named/named.lisi
   67  vim /etc/named/named.lisi
   68  vim /var/named/slaves/named.lisi
   69  vim /var/named/slaves/named.zhangsan 
   70  cd /var/named/slaves/
   71  ll
   72  ll /var/named/
   73  exit
   74  history
   75  exit
   76  vim /etc/named.conf
   77  systemctl restart named
   78  systemctl stop firewalld
   79  setenforce 0
   80  nmcli connection modify ens160 +ipv4.addresses 192.168.36.133/24
   81  nmcli connection modify ens160 ipv4.method manual
   82  nmcli connection up ens160
   83  cd /etc/httpd/conf.d/
   84  ll
   85  vim vhost.conf
   86  systemctl restart named
   87  systemctl restart httpd
   88  cd /www/
   89  cd
   90  mkdir www
   91  cd /www
   92  ll
   93  cd www
   94  mkdir 3031
   95  mkdir 3032
   96  mkdir 3033
   97  echo 3031 >/www/3031/index.html
   98  ll
   99  echo 3031 > /www/3031/index.html
  100  echo 3031 > /3031/index.html
  101  echo 3031 > 3031/index.html
  102  echo 3032 > 3032/index.html
  103  echo 3033 > 3033/index.html
  104  cd /etc/named.conf
  105  vim /etc/named.conf
  106  cd /var/named/
  107  ll
  108  cd /slaves/
  109  ll slaves/
  110  curl www.dadou.com
  111  systemctl restar named
  112  systemctl restart named
  113  systemctl restart httpd
  114  curl www.dadou.com
  115  systemctl stop firewalld
  116  setenforce 0
  117  curl www.dadou.com
  118  systemctl restart httpd
  119  systemctl restart named
  120  curl www.dadou.com
  121  curl www.xiaodou.com
  122  curl www.doudou.com
  123  cd
  124  systemctl start firewalld
  125  firewall-cmd --add-service=http --permanent
  126  firewall-cmd --add-service=dns --permanent
  127  firewall-cmd --add-port=3031 --permanent
  128  firewall-cmd --add-port=3031 --permanent 
  129  firewall-cmd --add-port=3031/tcp --permanent 
  130  firewall-cmd --add-port=3033/tcp --permanent 
  131  firewall-cmd --add-port=3032/tcp --permanent 
  132  firewall-cmd --reload
  133  setenforce 1
  134  semanage port -a -t http_port_t -p tcp 3031
  135  semanage port -a -t http_port_t -p tcp 3033
  136  semanage port -a -t http_port_t -p tcp 3032
  137  chcon -t httpd_sys_content_t /www/ -R
  138  cd /www
  139  ll
  140  cd www
  141  chcon -t httpd_sys_content_t www/ -R
  142  cd

 三、实验结果:

检查 httpd 服务是否正在运⾏:
[root@kittod conf.d # systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled;
vendor preset: disabled)
Active: active (running) (thawing) since Thu 2021-11-11 08: 00: 17
CST; 8min ago
Docs: man:httpd.service(8)
Main PID: 2227 (httpd)
Status: "Total requests: 5; Idle/Busy workers 100/0;Requests/sec:
0.0104; Bytes served/sec: 21 B/sec"
Tasks: 213 (limit: 49294)
Memory: 38.3M
CGroup: /system.slice/httpd.service
├─2227 /usr/sbin/httpd -DFOREGROUND
├─2228 /usr/sbin/httpd -DFOREGROUND
├─2229 /usr/sbin/httpd -DFOREGROUND
├─2230 /usr/sbin/httpd -DFOREGROUND
└─2231 /usr/sbin/httpd -DFOREGROUND
Nov 11 08: 00: 17 kittod systemd[1]: Starting The Apache HTTP
Server .
Nov 11 08: 00: 17 kittod systemd[1]: Started The Apache HTTP Server.
Nov 11 08: 00: 17 kittod httpd[2227]: Server confi gured, listening on:
port 9091, port 80

防火墙、SELinux呈开启状态下进行访问:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值