一、作业要求
1 、大家新建虚拟机一( 2 ~3 ) 台
2 、一台用来搭建httpd 服务, ( 1 ~2 ) 台用来做客户端访问测试
3 、要求, 针对httpd 服务节进行安全防护配置, 要求能够让客户端访问页面, 但尽量不要被攻击。
二、项目要求(思路)
新建三台虚拟机,其中一台命名为localhost,用于建立http服务
另外的两台分别命名为client1和client2。client1用于访问端页面,但是不能进行ssh连接。client2用于模拟攻击localhost,localhost需要禁止client2的访问来防止client2的攻击
三、项目架构
- 新建三台虚拟机:localhost,client1和client2
- 三台虚拟机的IP地址为:locallhost:192.168.6.130 ;client1:192.168.6.131; client2:192.168.6.132
四、执行方案
1、在localhost的/var/www/html/下新建index.html
执行命令为:
`[root@localhost html]# vi index.html
[root@localhost html]# cat index.html
执行的结果为:
2、
执行以下命令:
[root@localhost firewalld]# cd /etc/firewalld/
[root@localhost firewalld]# cd /etc/firewalld/services
[root@localhost services]# firewall-cmd --list-all
命令执行结果如下
3、添加并开启http服务
执行以下命令:
[root@localhost services]# systemctl start httpd
[root@localhost services]# firewall-cmd --add-service=http --permanent
[root@localhost services]# firewall-cmd reload
执行结果如下:
4、阻塞client2的访问
执行以下命令:
[root@localhost services]# firewall-cmd --add-rich-rule="rule family='ipv4' source address='192.168.6.132' reject" --permanent
[root@localhost services]# firewall-cmd --reload
[root@localhost services]# firewall-cmd --list-all
执行结果如下:
5、在client2端进连接localhost(192.168.6.130)操作
执行以下命令:
[root@client2 ~]# ping 192.168.6.130
[root@client2 ~]# ssh 192.168.6.130
[root@client2 ~]# curl 192.168.6.130
执行结果如下:
6、关闭client1(192.168.6.131)的ssh服务
执行以下命令:
[root@localhost services]# firewall-cmd --add-rich-rule="rule family='ipv4' source address='192.168.6.131' service name='ssh' reject" --permanent
[root@localhost services]# firewall-cmd --reload
[root@localhost services]# firewall-cmd --list-all
执行结果如下:
7、client1(192.168.6.131)对localhost进行访问
执行以下命令:
[root@client1 ~]# curl 192.168.6.130
[root@client1 ~]# ssh 192.168.6.130
[root@client1 ~]# ping 192.168.6.130
执行结果如下: