江西省职业技能大赛之路由器、防火墙配置、Apache部署

发布时间 2023-03-25 17:41:36作者: summer14

对FW进行配置,划分Office、DMZ、Inside区域为trust区域,Outside区域为untrust区域,使trust区域之间可以相互访问,untrust区域不能访问trust区域

 

int eth0
security-level 100
int eth1
security-level 100
int eth2
security-level 100
int eth3
security-level 0

//trust区域之间可以互相访问
same-security-traffic permit inter-interface

 

 

 

对ISP进行配置,使Outside区域PC能够访问DMZ区域

//对ISP只需要配置一条跳转到FW的路由
ip route 172.16.20.0 255.255.255.0 2.61.243.1

要想Outside和DMZ能够通信,还需对FW进行配置
  //首先放行来自outside,目的DMZ的流量
  access-list outside_access_dmz extended permit ip 185.6.12.0 255.255.255.0 172.16.20.0 255.255.255.0     //先定义ACL,允许访问DMZ的流量通过
  access-group outside_access_dmz in interface outside   //ACL部署在outside端口的入口

  //添加一条跳转到ISP的路由
  route outside 185.6.12.0 255.255.255.0 2.61.243.2

//Win_PC1是要配网关才能转发出去的

*asa删除一条ACL的命令:clear configure access-list outside_access_dmz

*路由器删除一条路由的命令:clear ip route ip mask

***ping不通,排查将近一小时,对比路由,查看放行规则,原来是改了security-level后没有保存。然后下次启动(一旦切屏就很可能会重启)时,outside和dmz的security-level相同,导致win_pc1发出的流量到达了dmz,但是回不来。切屏之前记得保存!!!!!!!!!!

 

在DCFW上配置SNAT功能,使Office区域能够访问Outside区域

//创建网络对象指定真实的ip地址池
ciscoasa(config)# object network office-outside-resource
ciscoasa(config-network-object)# range 172.16.30.2 172.16.30.253
//创建网络对象指定nat后的ip地址池
ciscoasa(config)# object network office-outside-natted
ciscoasa(config-network-object)# range 2.61.243.2 2.61.243.10

//nat
ciscoasa(config)# nat (office,outside) source dynamic office-outside-resource office-outside-natted
 
//winpc1 到office 的数据包目标ip是2.61.243.2-10/24,不会发给FW,ISP得加个路由
Router(config)#ip route 2.61.243.0 255.255.255.0 2.61.243.1

//流量到达防火墙,防火墙先将公有ip转为私有ip,然后再进行流量过滤
//由于回包是低安全区访问高安全区,所以放行从185.6.12.0/24到172.16.30.0/24的流量
ciscoasa(config)# access-list out-off extended permit ip 185.6.12.0 255.255.255.0 172.16.30.0 255.255.255.0
ciscoasa(config)# access-group out-off in interface outside

*查看定义的网络对象:sh run object network

*查看nat转换表:sh xlate

成功访问

   

 nat转换表

    

 

在Linux_Web上完成Apache的安装与部署

  eve-ng的镜像如何联网:EVE-NG 连接物理网络_eve-ng cloud_傍晚的烟火的博客-CSDN博客

  pnet1是eve-ng虚拟机的nat网卡

  

  在eve-ng web上对应的即为cloud 1

  

  测试一下:

   

  成功访问百度

  

 

安装Apache
    yum install httpd

systemctl stop firewalld   //先把防火墙关了再用Win_DNS访问,方便测试
配置域名为:web.worldcolleges.com   修改httpd.conf   ServerName web.worldcolleges.com 配置默认网站路径为/www/wwwroot   mkdir /www/wwwroot   修改httpd.conf     DocumentRoot "/var/www/html" 改为 DocumentRoot "/www/wwwroot"     <Directory "/var/www/html"> 改为 <Directory "/www/wwwroot"> 新建默认网页index.html,内容为:hello worldcolleges!   cd /www/wwwroot   echo "hello worldcolleges!" > index.html

更改了默认的网站路径后,访问index.html会出现“You don't have permission to access /index.html on this server”的错误
查看日志。奇奇怪怪的权限,应该跟selinux有关

问下bing AI

  

 

  SELinux 管理过程中,进程是否可以正确地访问文件资源,取决于它们的安全上下文。进程和文件都有自己的安全上下文,SELinux 会为进程和文件添加安全信息标签,比如 SELinux 用户、角色、类型、类别等,当运行 SELinux 后,所有这些信息都将作为访问控制的依据。   

  果然,两个文件的安全上下文不同

  

 

   递归更改网站根目录安全上下文

  

  

 访问成功!!!

 

对FW进行配置,使用2.61.243.220为Web做IP映射,并允许Outside、Inside和Office区域用户访问Web服务

 

Linux_Web防火墙先放行80端口的流量
  firewall-cmd --zone=public --add-port=80/tcp --permanent
  firewall-cmd --reload

对FW配置   创建Linux_Web网络对象     ciscoasa(config)#
object network Linux_Web     ciscoasa(config-network-object)# host 172.16.20.10   创建Linux_Web映射后的网络对象     ciscoasa(config)# object network Linux_Web_natted     ciscoasa(config-network-object)# host 2.61.243.220
  静态映射     nat (dmz,outside) source
static Linux_Web Linux_Web_natted

 

*查看防火墙状态:firewall-cmd --list-all

查看nat转换表

  

PC1成功使用公网ip访问Linux_Web,其他区域使用内网ip即可访问