博客
关于我
firewalld防火墙(一)
阅读量:515 次
发布时间:2019-03-07

本文共 2441 字,大约阅读时间需要 8 分钟。

基于区域、服务、端口的访问控制实验

实验环境

某公司的Web服务器和网关服务器均采用Linux CentOS 7.3操作系统。为了增强网络访问安全性,需熟悉Firewall防火墙规则编写,制定有效的主机防护策略。

实验拓扑

采用网络架构图(附图),详细描述网络设备分布和区域划分。

需求描述

  • 网关服务器

    • ens33网卡配置为trusted(信任)区域
    • ens34网卡配置为external(外部)区域
    • ens35网卡配置为dmz(非军事)区域
  • 网站服务器

    • SSH默认端口改为12345
      -开启HTTPS服务,过滤未加密的HTTP流量,且拒绝ping请求

实验步骤

Step 1:基本环境配置

  • 配置主机名及网卡地址

    • 网关服务器
      # 设定主机名为trusted[root@Centos ~]# hostnamectl set-hostname trusted
    • 企业内网测试机
      [root@trusted ~]# hostnamectl set-hostname trusted
    • 外部测试用机
      [root@externsl ~]# hostnamectl set-hostname externsl
    • 网站服务器
      [root@dmz ~]# hostnamectl set-hostname dmz
  • 更改SSH监听端口

    • 网关服务器
      [root@gateway ~]# vim /etc/ssh/sshd_config
    • 网站服务器
      [root@dmz ~]# vim /etc/ssh/sshd_config
    • 重新启动SSH服务:
      [root@gateway ~]# systemctl restart sshd
  • 开启网关服务器的路由转发功能

    [root@gateway ~]# vim /etc/sysctl.conf
  • Step 2:部署Web站点

  • 安装必要软件包

    [root@dmz ~]# yum -y install httpd mod_ssl
  • 启用并启动HTTPD服务

    [root@dmz ~]# systemctl start httpd
    [root@dmz ~]# systemctl enable httpd
  • 创建测试页面

    [root@dmz ~]# echo "this is a test web" > /var/www/html/index.html
  • Step 3:编写Firewalld防火墙规则

    关于网站服务器的规则
  • 启动Firewalld并设置默认区域

    [root@dmz ~]# systemctl start firewalld
    [root@dmz ~]# systemctl enable firewalld
    [root@dmz ~]# firewall-cmd --set-default-zone=dmz
  • 添加HTTPS和TCP12345端口

    [root@dmz ~]# firewall-cmd --zone=dmz --add-service=https --permanent
    [root@dmz ~]# firewall-cmd --zone=dmz --add-port=12345/tcp --permanent
  • 禁止ping请求

    [root@dmz ~]# firewall-cmd --add-icmp-block=echo-request --zone=dmz --permanent
  • 移除预定义SSH服务

    [root@dmz ~]# firewall-cmd --zone=dmz --remove-service=ssh --permanent
  • 重新加载Firewalld规则

    [root@dmz ~]# firewall-cmd --reload
  • 关于网关服务器的规则
  • 启动并设置默认区域

    [root@gateway ~]# systemctl start firewalld
    [root@gateway ~]# systemctl enable firewalld
    [root@gateway ~]# firewall-cmd --set-default-zone=external
  • 将ens32网卡设置为trusted区域,ens35设置为dmz区域

    [root@gateway ~]# firewall-cmd --change-interface=ens32 --zone=trusted
    [root@gateway ~]# firewall-cmd --change-interface=ens35 --zone=dmz
  • 添加external区域的TCP12345端口

    [root@gateway ~]# firewall-cmd --zone=external --add-port=12345/tcp --permanent
  • 移除SSH服务并禁止ping请求

    [root@gateway ~]# firewall-cmd --zone=external --remove-service=ssh --permanent
    [root@gateway ~]# firewall-cmd --zone=external --add-icmp-block=echo-request --permanent
  • 重新加载防火墙规则

    [root@gateway ~]# firewall-cmd --reload
  • 验证

  • 互联网测试计算机通过SSH登录外部接口12345端口

    [root@externsl ~]# ssh -p 12345 192.168.200.20
  • 企业内网测试计算机通过SSH登录网站服务器12345端口

    [root@trusted ~]# ssh -p 12345 192.168.10.10
  • 企业内网测试机访问网站服务器

    [图片描述:测试访问网站服务器]

  • 转载地址:http://wbbnz.baihongyu.com/

    你可能感兴趣的文章
    Python - 如何在 Windows 10 上完全卸载 Anaconda?
    查看>>
    python - 如何并行化python numpy中的总和计算?
    查看>>
    Python - 如何解析 xml 响应并将元素值存储在变量中?
    查看>>
    Python - 安装了扩展的远程 Webdriver
    查看>>
    python - 将字符串中的日期与今天的日期进行比较
    查看>>
    python - 数据描述符(class 内置 get/set/delete方法 )
    查看>>
    Python - 根据值绘制彩色网格
    查看>>
    Python - 正则表达式在括号之间获取数字
    查看>>
    Python - 正则表达式在括号之间获取数字
    查看>>
    Python - 正则表达式在括号之间获取数字
    查看>>
    Python - 类 __hash__ 方法和集合
    查看>>
    Python - 轻松将文本文件内容转换为字典值/键
    查看>>
    Python - 递归和列表
    查看>>
    Python 3 读取ini文件
    查看>>
    Python 3.0 使用 turtle.onclick
    查看>>
    Python 3.10 明年发布,看看都有哪些新特性?
    查看>>
    python 3.10上安装pyqt5
    查看>>
    Python 3.12 正式发布了!
    查看>>
    Python 3.2 中的蛮力脚本
    查看>>
    Python 3.4 多处理递归 Pool.map()
    查看>>