1. 火墙介绍
Netfilter/IPTables是Linux2.4.x之后新一代的Linux防火墙机制,是linux内核的一个子系统。Netfilter采用模块化设计,具有良好的可扩充性。其重要工具模块IPTables从用户态的iptables连接到内核态的Netfilter的架构中,Netfilter与IP协议栈是无缝契合的,并允许使用者对数据报进行过滤、地址转换、处理等操作。
管理方式iptables|firewalld
2. 火墙管理工具切换
在rhel8中默认为firewalld
2.1 将firewalld切换为iptables
systemctl stop firewalld
systemctl disable firewalld
systemctl mask firewalld
dnf search iptables
dnf install iptables-services.x86_64 -y
systemctl enable --now iptables.service
2.2 将iptables切换为firewalld
systemctl stop iptables
systemctl disable iptables
systemctl mask iptables
systemctl unmask firewalld
systemctl enable --now firewalld
3. iptables
3.1 iptables的使用
/etc/sysconfig/iptables
iptales-save > /etc/sysconfig/iptables
service iptables save
3.2 火墙默认策略

链 |
作用 |
input |
输入 |
output |
输出 |
forward |
转发 |
postrouting |
路由之后 |
prerouting |
路由之前 |
表 |
功能 |
filter |
经过本机内核的数据(input output forward) |
nat |
不经过内核的数据(postrouting prerouting input output) |
mangle |
当filter和nat表不够用时使用该表(input output forward postrouting prerouting) |
3.3 iptables的命令
命令 |
参数 |
作用 |
iptables |
-t |
指定表名称 |
iptables |
-n |
不做解析 |
iptables |
-L |
查看 |
iptables |
-A |
添加策略 |
iptables |
-p |
协议 |
iptables |
–dport |
目的地端口 |
iptables |
-s |
来源 |