本次是一个Firewalld的基础操作实例,利用Firewalld图形操作界面进行访问控制操作。


实验拓扑

需求分析

首先拓扑涉及到两个区域,这里使用workpublic区域,分别做相应的规则。

1.work区域禁止icmp,允许192.168.100.101访问SSH服务,同时允许访问Apache服务。

2.public区域禁止icmp,禁止SSH服务,允许访问Apache服务。

分析方法:基于Firewalld的数据处理流程,可参考上一篇博客

操作过程

基础准备

  • server安装Apache服务,默认已存在SSH服务。
[root@server ~]# yum install -y httpd
[root@server ~]# echo "This is test page , all host can access" > /var/www/html/index.html
[root@server ~]# systemctl start httpd.service
  • 默认不关闭防火墙的情况下,可以pingssh,不可以访问apache
[root@host01 ~]# ping -c4 192.168.100.100
PING 192.168.100.100 (192.168.100.100) 56(84) bytes of data.
64 bytes from 192.168.100.100: icmp_seq=1 ttl=64 time=0.573 ms
64 bytes from 192.168.100.100: icmp_seq=2 ttl=64 time=0.575 ms
64 bytes from 192.168.100.100: icmp_seq=3 ttl=64 time=1.15 ms
64 bytes from 192.168.100.100: icmp_seq=4 ttl=64 time=0.441 ms --- 192.168.100.100 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 0.441/0.686/1.156/0.277 ms
[root@host01 ~]# curl 192.168.100.100
curl: (7) Failed connect to 192.168.100.100:80; No route to host
[root@host01 ~]# ssh root@192.168.100.100
The authenticity of host '192.168.100.100 (192.168.100.100)' can't be established.
ECDSA key fingerprint is SHA256:5GGc1rmzWwjF+ozz/PPTyLO2s6NmFHSxbzCNsLazXhY.
ECDSA key fingerprint is MD5:0b:f5:62:d7:a4:1f:05:64:0b:7f:22:62:11:64:07:61.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.100' (ECDSA) to the list of known hosts.
root@192.168.100.100's password:
Last login: Wed Oct 23 09:55:12 2019
[root@server ~]# logout
Connection to 192.168.100.100 closed.

配置 Firewalld

[root@server ~]# firewall-config
  • work区域添加来源:192.168.100.101

  • 允许work区域的httpssh服务,禁止其他存在的服务

  • 允许public区域的http服务,禁止其他存在的服务

  • 通过ICMP过滤器禁止request请求,在两个区域都做。

结果验证

  • 网站访问
[root@host01 ~]# curl 192.168.100.100
This is test page , all host can access
[root@host02 ~]# curl 192.168.100.100
This is test page , all host can access
  • SSH远程
[root@host01 ~]# ssh root@192.168.100.100
root@192.168.100.100's password:
Last login: Wed Oct 23 10:47:15 2019
[root@server ~]# logout
Connection to 192.168.100.100 closed.
[root@host02 ~]# ssh root@192.168.100.100
ssh: connect to host 192.168.100.100 port 22: No route to host
  • ping测试
[root@host01 ~]# ping -c4 192.168.100.100
PING 192.168.100.100 (192.168.100.100) 56(84) bytes of data.
From 192.168.100.100 icmp_seq=1 Destination Host Prohibited
From 192.168.100.100 icmp_seq=2 Destination Host Prohibited
From 192.168.100.100 icmp_seq=3 Destination Host Prohibited
From 192.168.100.100 icmp_seq=4 Destination Host Prohibited --- 192.168.100.100 ping statistics ---
4 packets transmitted, 0 received, +4 errors, 100% packet loss, time 3001ms
[root@host02 ~]# ping -c4 192.168.100.100
PING 192.168.100.100 (192.168.100.100) 56(84) bytes of data.
From 192.168.100.100 icmp_seq=1 Destination Host Prohibited
From 192.168.100.100 icmp_seq=2 Destination Host Prohibited
From 192.168.100.100 icmp_seq=3 Destination Host Prohibited
From 192.168.100.100 icmp_seq=4 Destination Host Prohibited --- 192.168.100.100 ping statistics ---
4 packets transmitted, 0 received, +4 errors, 100% packet loss, time 3002ms

永久配置

  • 设置永久配置

  • 这里配置的是运行时配置,若要更改永久配置需点击选项,首先将Runtime设定为永久配置,然后重载防火墙,直接重载防火墙会丢失运行时的配置。

  • 若是一开始就选择的永久配置,则可以直接重载防火墙使配置生效。

Linux Firewalld 基础实例的更多相关文章

  1. Linux Firewalld 基础介绍

    互联网上提供了各种网络服务,而防火墙可以设置各种规则来限制访问,保护服务器. 概述 Linux的防火墙体系主要工作在网络层,针对TCP/IP数据包实施过滤和限制,属于典型的包过滤防火墙. Linux系 ...

  2. Linux 系统基础优化和常用命令

    目录 Linux 系统基础优化和常用命令 软连接 tar解压命令 gzip命令 netstart命令 ps命令 kill命令 killall命令 SELinux功能 iptables防火墙 Linux ...

  3. linux(03)基础系统优化

    Linux之基础系统优化 Linux基础系统优化 >>> https://www.cnblogs.com/pyyu/p/9355477.html Linux的网络功能相当强悍,一时之 ...

  4. 运维 07 Linux系统基础优化及常用命令

    Linux系统基础优化及常用命令   Linux基础系统优化 引言没有,只有一张图. Linux的网络功能相当强悍,一时之间我们无法了解所有的网络命令,在配置服务器基础环境时,先了解下网络参数设定命令 ...

  5. Kali Linux渗透基础知识整理(四):维持访问

    Kali Linux渗透基础知识整理系列文章回顾 维持访问 在获得了目标系统的访问权之后,攻击者需要进一步维持这一访问权限.使用木马程序.后门程序和rootkit来达到这一目的.维持访问是一种艺术形式 ...

  6. Kali Linux渗透基础知识整理(二)漏洞扫描

    Kali Linux渗透基础知识整理系列文章回顾 漏洞扫描 网络流量 Nmap Hping3 Nessus whatweb DirBuster joomscan WPScan 网络流量 网络流量就是网 ...

  7. 5.linux内核模块基础,内核模块学习

    linux内核模块基础 一.定义 Linux 内核的整体结构非常庞大,其包含的组件也非常多,如何使用这些组件呢: 方法 1:把所有的组件都编译进内核文件,即:zImage 或 bzImage,但这样会 ...

  8. Linux常用基础命令整理:关机命令、查看目录下文件命令等

    Linux常用基础命令整理:关机命令.查看目录下文件命令等 整理了一些Linux常用基础命令,欢迎指正. 首先记住四个热键,学会这四个键,收益一辈子. Tab按键---命令补齐功能Ctrl+c按键-- ...

  9. 小朋友学Linux<一>基础篇

    Linux最基础之<小朋友也能学会Linux>... 1.Linux 知识积累: Linux 英文解释为 Linux is not Unix.学习Linux必须要熟练使用的操作系统是Cen ...

随机推荐

  1. LOJ 数列分块入门系列

    目录 1.区间加+单点查 每个块维护tag,散的暴力改. code: #include<bits/stdc++.h> using namespace std; const int maxn ...

  2. Chrome 禁止 http 自动转化为https

    Chrome 浏览器 地址栏中输入 chrome://net-internals/#hsts 在 Delete domain security policies 中输入项目的域名,并 Delete 删 ...

  3. 在springboot中使用redis缓存,将缓存序列化为json格式的数据

    背景 在springboot中使用redis缓存结合spring缓存注解,当缓存成功后使用gui界面查看redis中的数据 原因 springboot缓存默认的序列化是jdk提供的 Serializa ...

  4. Bootstrap-table实现动态合并相同行

    Bootstrap-table  表格合并相同名字的列 @编写function() /** * 合并行 * @param data 原始数据(在服务端完成排序) * @param fieldName ...

  5. [LeetCode] 895. Maximum Frequency Stack 最大频率栈

    Implement FreqStack, a class which simulates the operation of a stack-like data structure. FreqStack ...

  6. [LeetCode] 633. Sum of Square Numbers 平方数之和

    Given a non-negative integer c, your task is to decide whether there're two integers a and b such th ...

  7. [LeetCode] 491. Increasing Subsequences 递增子序列

    Given an integer array, your task is to find all the different possible increasing subsequences of t ...

  8. C++ 10进制, 16进制, ASCII码, 单字节与多字节的相互转换

    这些简单的转换是用的比较频繁的, 因此将这些功能全部封装在一个类中 头文件 #pragma once #include <stdlib.h> #include <string> ...

  9. Linux系统运维笔记,CentOS 7.4防火墙配置

    1.查看firewall服务状态 systemctl status firewalld 2.查看firewall的状态 firewall-cmd --state 3.开启.重启.关闭.firewall ...

  10. [BAT脚本] 1、BAT脚本FOR循环操作文件和命令返回实例

    Wednesday, 31. October 2018 08:18PM - beautifulzzzz 一.需求 需要在windows上实现一个bat脚本解析json,将json转换为自己想要的key ...