iptables 配置规则工具的使用
在红帽RHEL7系统中firewalld服务取代了iptables服务,如想继续使用iptables按以下操作
服务器需要关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
服务器关闭网桥功能
systemctl stop firewalld.service
systemctl disable firewalld.service
4张表
raw 流量跟踪
mangle 流量整形
nat 网络地址转换
filter 过滤
如果在表中写规则 链 chain
filter:
INPUT 入站(数据包是访问我的)
FORWARD 转发(数据包通过我访问别人)
OUTPUT 出站(我的数据向 外发送)
查看不同的的表规则命令
iptables -t nat -nvL
iptables -t filter -nvL
配置服务器icmp拒绝后如何观察数据包变化
watch -n1 iptables -nvL 实时观察 ctrl+c终止
iptables 防护规则的原则
iptables -I INPUT -p icmp -j REJECT 拒绝icmp协议通过
iptables -I INPUT -p icmp -j ACCEPT 允许icmp协议通过
iptables规则的删除
防火墙编写规则明细
常见的控制类型.
(只有ACCEPT和DROP可以设定为默认的控制类型)
ACCEPT 允许访问
REJECT 拒绝访问
DROP 丢弃数据
LOG 只做记录不做限制
常见选项
-I 插入
-D 删除单个规则
-F清空链的所有规则
-P 设定默认规则
-A 规则追加
-nvL --line-number 查看规则信息
防火墙的条件匹配规则
通用匹配 可以独立使用
-P 协议(tcp icmp udp all)-s 原地址 -d 目标地址 -i 入口(网口) -o 出口(网口)
隐含匹配 不可以独立使用 (隐含在其他的匹配条件中)
--dpor 指定目标端口 绑定通用匹配 -p 使用
--icmp-type (8请求0回显3不可达)
服务器ping别人能看到ping通的效果,别人ping我 丢弃。