0
点赞
收藏
分享

微信扫一扫

第八章iptables防火墙

安装iptables服务

保存不上,可能没安装iptables服务

yum install iptables-services.x86_64


关闭防火墙

systemctl stop firewalld

systemctl mask firewalld

 2 安装 iptables 服务

yum install iptables-services

 3 设置 iptables 服务开机启动

systemctl enable iptables

 4 重启 iptables 服务

systemctl restart iptables

 5 执行保存配置命令

service iptables save


iIptables防火墙

第八章iptables防火墙_丢包


防火墙特性

从上往下

第八章iptables防火墙_丢包_02



一旦满足就不会在往下匹配


但全拒绝时,应该是允许的,


Iptables 红帽7以后没有了

Iptables -L //查看规则链

Iptables -F //清空规则链

Iptables -P //设置默认策略

iptables -I INPUT  //头部添加规则

iptables -A INPUT // 尾部添加规则

Iptables -p //匹配的协议

Iptables -j //是否允许的动作

-j ACCEPT DrOP PEJECT LOG

允许流量 拒绝流量 拒绝   记录日志

DrOP是不理睬的拒绝,不搭理你,丢包

PEJECT 有回应的拒绝

LOG 记录日志

iptables -D num //删除某条规则

iptables -S //来源的IP地址

!除了这个IP外


iptables -i //网卡流入的数据

iptables -o //网卡流出的数据


保存永久生效

service iptables save 


实验


首先清空规则

Iptables -F

然后查看

iptables -L

第八章iptables防火墙_记录日志_03




写入默认设置

DrOP全拒绝

Iptables -P INPUT DrOP

默认只能写,DrOP,


写入规则

Ping的协议是ICMP

iptables -I INPUT -p icmp -j ACCEPT


在考试的时候,如果要拒绝,写PEJECT


在默认规则里,只能设置DrOP丢包,不能设置PEJECT


删除一条规则

iptables -D INPUT 1


设置允许192.168.10.0/24网段的tcp协议的22端口号的请求,

Iptables -I input -s 192.168.10.0/24 -p tcp --dport=22 -j ACCEPT


设置除了这个网段,其他的都不行

Iptables -I input -s 192.168.10.0/24 -p tcp --dport=22 -j ACCEPT

iptables -A INPUT -p tcp --dport=22 -j rEJECT


I是头 A是尾

把允许动作放在拒绝动作前面,

要不所有流量都被拒绝


拒绝所有人访问本机12345端口

Iptables -I INPUT -p tcp --dport 12345 -j rEJECT


拒绝192.168.10.5访问80端口 web服务

Iptables -I INPUT -s 192.168.10.5 -p tcp --dport 80 -j rEJECT


拒绝所有主机访问1000~1024端口

-A兜底 //让所有进来,最后淘汰

iptables -A INPUT -p tcp --dport 1000:1024 -j rEJECT

iptables -A INPUT -p udp --dport 1000:1024 -j rEJECT


禁止1500

是tcp

udp??

建议都写上,


保存永久生效

service iptables save

举报

相关推荐

0 条评论