Linux firewalld使用教程+rhce课程实验
--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课程实验的更多相关文章
- 《Java程序设计》课程实验要求
目录 <Java程序设计>课程实验要求 注册实验楼账号 实验一 Java开发环境的熟悉 实验二<Java面向对象程序设计> 实验三 <敏捷开发与XP实践> 实验四 ...
- 《嵌入式Linux开发实用教程》
<嵌入式Linux开发实用教程> 基本信息 作者: 朱兆祺 李强 袁晋蓉 出版社:人民邮电出版社 ISBN:9787115334831 上架时间:2014-2-13 出版日期: ...
- CTF必备技能丨Linux Pwn入门教程——PIE与bypass思路
Linux Pwn入门教程系列分享如约而至,本套课程是作者依据i春秋Pwn入门课程中的技术分类,并结合近几年赛事中出现的题目和文章整理出一份相对完整的Linux Pwn教程. 教程仅针对i386/am ...
- CTF必备技能丨Linux Pwn入门教程——格式化字符串漏洞
Linux Pwn入门教程系列分享如约而至,本套课程是作者依据i春秋Pwn入门课程中的技术分类,并结合近几年赛事中出现的题目和文章整理出一份相对完整的Linux Pwn教程. 教程仅针对i386/am ...
- CTF必备技能丨Linux Pwn入门教程——ROP技术(上)
Linux Pwn入门教程系列分享如约而至,本套课程是作者依据i春秋Pwn入门课程中的技术分类,并结合近几年赛事中出现的题目和文章整理出一份相对完整的Linux Pwn教程. 教程仅针对i386/am ...
- CTF必备技能丨Linux Pwn入门教程——环境配置
说在前面 这是一套Linux Pwn入门教程系列,作者依据Atum师傅在i春秋上的Pwn入门课程中的技术分类,并结合近几年赛事中出现的一些题目和文章整理出一份相对完整的Linux Pwn教程. 问:为 ...
- linux 第七周 总结及实验
姬梦馨 原创作品 <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 第七周 Linux内核如何装载和启动一 ...
- Linux Capabilities 入门教程:基础实战篇
该系列文章总共分为三篇: Linux Capabilities 入门教程:概念篇 Linux Capabilities 入门教程:基础实战篇 待续... 上篇文章介绍了 Linux capabilit ...
- CTF丨Linux Pwn入门教程:针对函数重定位流程的相关测试(下)
Linux Pwn入门教程系列分享已接近尾声,本套课程是作者依据i春秋Pwn入门课程中的技术分类,并结合近几年赛事中出现的题目和文章整理出一份相对完整的Linux Pwn教程. 教程仅针对i386/a ...
随机推荐
- 2.python发展历程
创始人:吉多·范罗苏姆于1989年圣诞节在阿姆斯特丹编写 python分为: python 2.X python 3.X 使用python的公司: 豆瓣.BT.Dropbox.YouTube.Quor ...
- 关于动态内存malloc和realloc
1.malloc 1.申请的内存长度可以运行时决定,单位是字节 2.申请的内存为连续的内存空间 3.返回的地址可以根据实际需要强转成对应的类型 4.动态申请内存的生命周期是整个程序,除非手动 ...
- Mycat 镜像-创建 Docker 镜像
将 Mycat-server 创建到镜像,使其能够进行容器化部署,我们需要创建 Dockerfile 并在文件中安装其依赖项,使用 centos 做为 base 镜像,并安装 jdk 依赖即可,因此创 ...
- ubuntu12.04 64bit libncurses5-dev和libncurses5-dev:i386共存性问题讨论
ubuntu12.04 64bit 编译kernel(或者make menuconfig)源码时出现如下错误: HOSTLD scripts/kconfig/mconf scripts/kconfig ...
- 阿里四不像Fourinone
阿里四不像——分布式核心技术框架 Fourinone https://blog.csdn.net/shero_zsmj/article/details/52277194
- Android开发 :androidstudio device offline
使用设备调试的时候,偶尔的就会遇到androidstudio device offline,尽管尝试开启/关闭 USB调试 .都无济于事. 如果PC安装了360手机助手就好办了(我的360手机助手 ...
- iterator简单描述
Item 26. Prefer iterator to const iterator, reverse_iterator, and const_reverse_iterator. 上面一段话,是< ...
- MySQL 大数据备份方案之Percona XtraBackup
Xtrabackup介绍 1.Xtrabackup是什么 Xtrabackup是一个对InnoDB做数据备份的工具,支持在线热备份(备份时不影响数据读写),是商业备份工具InnoDB Hotbacku ...
- SAS 评分卡开发模型变量统计及输出
以下代码实现功能: 1.获取10个模型分别使用哪些变量 2.变量所模型使用的次数 3.把上表格输出到EXCEL中 %INCLUDE '00@HEADER.SAS'; %let dir=..\04@Mo ...
- 记录 Ext 日历月份选择控件bug解决过程结果
目录 背景 代码 背景 项目使用 Ext.NET 2.2.0.40838 , 对应 Ext JS4.2 版本. 结果 2017/3/31 号的时候偶然间点日历选择控件选择2月,10月等月份突然就跳到3 ...