--timeout=  设置规则生效300秒

调试阶段使用,防止规则设置错误导致无法远程连接

实验:
在server0机器上部署httpd服务,通过添加富规则,只允许172.25.0.10/32访问,并且记录日志,日志级别为notice,日志前注为"NEW HTTP",限制每秒3个并发,要求持久化生效

1、在server0上执行
yum install httpd -y
systemctl start httpd
systemctl enable httpd

[root@server0 zones]# yum install httpd -y
[root@server0 zones]# systemctl start httpd
[root@server0 zones]# systemctl enable httpd
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
[root@server0 zones]# lsof -i:80 -n
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 8386 root 4u IPv6 44433 0t0 TCP *:http (LISTEN)
httpd 8387 apache 4u IPv6 44433 0t0 TCP *:http (LISTEN)
httpd 8388 apache 4u IPv6 44433 0t0 TCP *:http (LISTEN)
httpd 8389 apache 4u IPv6 44433 0t0 TCP *:http (LISTEN)
httpd 8390 apache 4u IPv6 44433 0t0 TCP *:http (LISTEN)
httpd 8391 apache 4u IPv6 44433 0t0 TCP *:http (LISTEN)
httpd 8392 apache 4u IPv6 44433 0t0 TCP *:http (LISTEN)

  

此时desktop机器是无法访问网页,但是server0机器可以看到网页

[root@desktop0 ~]# curl http://server0
curl: (7) Failed connect to server0:80; No route to host [root@server0 ~]# curl localhost
hello world

  

因为firewalld中并没有允许http协议的连接连进来

[root@server0 ~]# firewall-cmd --list-all
You're performing an operation over default zone ('public'),
but your connections/interfaces are in zone 'ROL' (see --get-active-zones)
You most likely need to use --zone=ROL option. public (default)
interfaces:
sources:
services: dhcpv6-client ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
所有的zones都没有允许,所以外部访问会被拦截 [root@server0 ~]# firewall-cmd --get-default-zone
public
[root@server0 ~]# firewall-cmd --list-all-zones
ROL
interfaces:
sources: 172.25.0.252/32
services: ssh vnc-server
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules: block
interfaces:
sources:
services:
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules: dmz
interfaces:
sources:
services: ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules: drop
interfaces:
sources:
services:
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules: external
interfaces:
sources:
services: ssh
ports:
masquerade: yes
forward-ports:
icmp-blocks:
rich rules: home
interfaces:
sources:
services: dhcpv6-client ipp-client mdns samba-client ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules: internal
interfaces:
sources:
services: dhcpv6-client ipp-client mdns samba-client ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules: public (default)
interfaces:
sources:
services: dhcpv6-client ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules: trusted
interfaces:
sources:
services:
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules: work
interfaces:
sources:
services: dhcpv6-client ipp-client ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:

  

我们设置一下防火墙的规则

[root@server0 ~]# firewall-cmd --permanent --add-rich-rule=' rule family=ipv4 source address="172.25.0.10/32" service name="http" log prefix="NEW HTTP " level=notice limit value="3/s" accept  '
You're performing an operation over default zone ('public'),
but your connections/interfaces are in zone 'ROL' (see --get-active-zones)
You most likely need to use --zone=ROL option.

  

success
重新加载 一下
[root@server0 ~]# firewall-cmd --reload
success
查看规则,已经可以看到刚才添加的规则已生效
[root@server0 ~]# firewall-cmd --list-all
You're performing an operation over default zone ('public'),
but your connections/interfaces are in zone 'ROL' (see --get-active-zones)
You most likely need to use --zone=ROL option
public (default)
interfaces:
sources:
services: dhcpv6-client ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
rule family="ipv4" source address="172.25.0.10/32" service name="http" log prefix="NEW HTTP " level="notice" limit value="3/s" accept
查看firewalld xml文件
[root@server0 ~]# cat /usr/lib/firewalld/zones/public.xml
<?xml version="1.0" encoding="utf-8"?>
<zone>
<short>Public</short>
<description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
<service name="ssh"/>
<service name="dhcpv6-client"/>
</zone>
[root@server0 ~]#
重新进行页面访问,发现已经可以访问了
[root@desktop0 ~]# curl http://172.25.0.11
hello world
[root@desktop0 ~]#

  

查看日志,日志中已经记载出来了

[root@server0 ~]# cat /var/log/messages  | tail -n 1
Dec 23 18:22:37 localhost kernel: NEW HTTP IN=eth0 OUT= MAC=52:54:00:00:00:0b:52:54:00:00:00:0a:08:00 SRC=172.25.0.10 DST=172.25.0.11 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=8704 DF PROTO=TCP SPT=48464 DPT=80 WINDOW=14600 RES=0x00 SYN URGP=0
[root@server0 ~]#

  

附加:拒绝另一个地址链接,并且记录日志

添加一条规则,并且重新加载

[root@server0 ~]# firewall-cmd --permanent --add-rich-rule=' rule family=ipv4 source address="172.25.0.1/24" service name=http log level=notice prefix="HARD_LOG " reject  '
You're performing an operation over default zone ('public'),
but your connections/interfaces are in zone 'ROL' (see --get-active-zones)
You most likely need to use --zone=ROL option. success [root@server0 ~]# firewall-cmd --reload
success
[root@server0 ~]# firewall-cmd --list-all
You're performing an operation over default zone ('public'),
but your connections/interfaces are in zone 'ROL' (see --get-active-zones)
You most likely need to use --zone=ROL option. public (default)
interfaces:
sources:
services: dhcpv6-client ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
rule family="ipv4" source address="172.25.0.1/24" service name="http" log prefix="HARD_LOG " level="notice" reject
rule family="ipv4" source address="172.25.0.10/32" service name="http" log prefix="NEW HTTP " level="notice" limit value="3/s" accept
[root@server0 ~]#

  

另一个地址进行访问,但是没有访问进来,查看日志,可以看到访问记录

[root@server0 ~]# cat /var/log/messages  | grep HARD_LOG
Dec 23 18:40:51 localhost kernel: HARD_LOG IN=eth0 OUT= MAC=52:54:00:00:00:0b:00:50:56:c0:00:01:08:00 SRC=172.25.0.1 DST=172.25.0.11 LEN=52 TOS=0x00 PREC=0x00 TTL=128 ID=27789 DF PROTO=TCP SPT=56158 DPT=80 WINDOW=8192 RES=0x00 SYN URGP=0

  

Linux firewalld使用教程+rhce课程实验的更多相关文章

  1. 《Java程序设计》课程实验要求

    目录 <Java程序设计>课程实验要求 注册实验楼账号 实验一 Java开发环境的熟悉 实验二<Java面向对象程序设计> 实验三 <敏捷开发与XP实践> 实验四 ...

  2. 《嵌入式Linux开发实用教程》

    <嵌入式Linux开发实用教程> 基本信息 作者: 朱兆祺    李强    袁晋蓉 出版社:人民邮电出版社 ISBN:9787115334831 上架时间:2014-2-13 出版日期: ...

  3. CTF必备技能丨Linux Pwn入门教程——PIE与bypass思路

    Linux Pwn入门教程系列分享如约而至,本套课程是作者依据i春秋Pwn入门课程中的技术分类,并结合近几年赛事中出现的题目和文章整理出一份相对完整的Linux Pwn教程. 教程仅针对i386/am ...

  4. CTF必备技能丨Linux Pwn入门教程——格式化字符串漏洞

    Linux Pwn入门教程系列分享如约而至,本套课程是作者依据i春秋Pwn入门课程中的技术分类,并结合近几年赛事中出现的题目和文章整理出一份相对完整的Linux Pwn教程. 教程仅针对i386/am ...

  5. CTF必备技能丨Linux Pwn入门教程——ROP技术(上)

    Linux Pwn入门教程系列分享如约而至,本套课程是作者依据i春秋Pwn入门课程中的技术分类,并结合近几年赛事中出现的题目和文章整理出一份相对完整的Linux Pwn教程. 教程仅针对i386/am ...

  6. CTF必备技能丨Linux Pwn入门教程——环境配置

    说在前面 这是一套Linux Pwn入门教程系列,作者依据Atum师傅在i春秋上的Pwn入门课程中的技术分类,并结合近几年赛事中出现的一些题目和文章整理出一份相对完整的Linux Pwn教程. 问:为 ...

  7. linux 第七周 总结及实验

    姬梦馨 原创作品 <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 第七周 Linux内核如何装载和启动一 ...

  8. Linux Capabilities 入门教程:基础实战篇

    该系列文章总共分为三篇: Linux Capabilities 入门教程:概念篇 Linux Capabilities 入门教程:基础实战篇 待续... 上篇文章介绍了 Linux capabilit ...

  9. CTF丨Linux Pwn入门教程:针对函数重定位流程的相关测试(下)

    Linux Pwn入门教程系列分享已接近尾声,本套课程是作者依据i春秋Pwn入门课程中的技术分类,并结合近几年赛事中出现的题目和文章整理出一份相对完整的Linux Pwn教程. 教程仅针对i386/a ...

随机推荐

  1. day03字符串

    字符串 1.方法详细内容 方法 强制转换 ##### 1.大小写转换 Value.upper() / value.lower() new_value=value.upper() print(new_v ...

  2. c# 状态机实现

    c#仿boost statechart的状态机.去年转到unity使用c#,statechart原来的风格蛮爽的,缺点是编译忒慢,在c#则编译根本不是问题. 不一样的地方首先是简单!因为没做一些东西如 ...

  3. windows7 64位安装tensorflow 1.4.0 CPU版本

    机器学习和深度学习真是新生代的宠儿,我也被安排来搞这个了,这下是真的从0开始了.看了几天ppt,想跑跑代码试试,装个环境. 都说tensorflow很火很好用,反正我什么也不懂,准备把这些框架一个一个 ...

  4. JavaScript图形库

    做前端少不了画图,html5 的 canva 很强大,可是如果所有需求都自己画图,恐怕会被 leader 炒掉.记录一下我用过的几个 2D 和 3D 的js图形库,各种功能.我就不分 2D 和 3D ...

  5. 对Array.prototype.slice.call()方法的理解

    在看别人代码时,发现有这么个写法:[].slice.call(arguments, 0),这到底是什么意思呢? 1.基础 1)slice() 方法可从已有的数组中返回选定的元素. start:必需.规 ...

  6. Python安装与Pycharm使用入门

    一.安装Python 1.Linux下安装 一般系统默认已安装2.6.6版本,升级成2.7版本, 但 2.6 不能删除,因为系统对它有依赖,epel源里最新的也是2.6版本,所以以源代码的方式安装2. ...

  7. MySQL导出数据字典

    平时用mysql比较多,有时候需要详细的数据库设计表结构和数据字典,但又没有最新的文档,这个时候直接从数据导出是最新最全的.在MySQL数据库中利用information_schema库中的COLUM ...

  8. JQuery miniui使用小记

    1.renderer="onActionRenderer" 如我们需要在一行数据时加上删除操作时,就需要在每行上加上“删除”按钮,以下为实现代码: 列加载时主要的属性

  9. XAMPP 虚拟主机配置,实现多域名访问本地项目

    XAMPP 虚拟主机配置,实现多域名访问本地项目 1.首先你既然要配置多个虚拟主机,那你肯定需要多个站点的目录文件.你可以在e盘创建 www文件夹,然后在该文件件中新建两个站点目录,假设test.co ...

  10. Codeforces Round #551 (Div. 2) A-E

    A. Serval and Bus 算出每辆车会在什么时候上车, 取min即可 #include<cstdio> #include<algorithm> #include< ...