linux下IPTABLES配置详解

开始配置

我们来配置一个filter表的防火墙.

(1)查看本机关于IPTABLES的设置情况

[root@tp ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target       prot opt source                 destination         

Chain FORWARD (policy ACCEPT)
target       prot opt source                 destination         

Chain OUTPUT (policy ACCEPT)
target       prot opt source                 destination         

Chain RH-Firewall-1-INPUT (0 references)
target       prot opt source                 destination         
ACCEPT       all    --    0.0.0.0/0              0.0.0.0/0           
ACCEPT       icmp --    0.0.0.0/0              0.0.0.0/0             icmp type 255 
ACCEPT       esp    --    0.0.0.0/0              0.0.0.0/0           
ACCEPT       ah     --    0.0.0.0/0              0.0.0.0/0           
ACCEPT       udp    --    0.0.0.0/0              224.0.0.251           udp dpt:5353 
ACCEPT       udp    --    0.0.0.0/0              0.0.0.0/0             udp dpt:631 
ACCEPT       all    --    0.0.0.0/0              0.0.0.0/0             state RELATED,ESTABLISHED 
ACCEPT       tcp    --    0.0.0.0/0              0.0.0.0/0             state NEW tcp dpt:22 
ACCEPT       tcp    --    0.0.0.0/0              0.0.0.0/0             state NEW tcp dpt:80 
ACCEPT       tcp    --    0.0.0.0/0              0.0.0.0/0             state NEW tcp dpt:25 
REJECT       all    --    0.0.0.0/0              0.0.0.0/0             reject-with icmp-host-prohibited 
可以看出我在安装linux时,选择了有防火墙,并且开放了22,80,25端口.

如果你在安装linux时没有选择启动防火墙,是这样的

[root@tp ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target       prot opt source                 destination         

Chain FORWARD (policy ACCEPT)
target       prot opt source                 destination         

Chain OUTPUT (policy ACCEPT)
target       prot opt source                 destination  

什么规则都没有.

(2)清除原有规则.

不管你在安装linux时是否启动了防火墙,如果你想配置属于自己的防火墙,那就清除现在filter的所有规则.

[root@tp ~]# iptables -F        清除预设表filter中的所有规则链的规则
[root@tp ~]# iptables -X        清除预设表filter中使用者自定链中的规则

我们在来看一下

[root@tp ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target       prot opt source                 destination         

Chain FORWARD (policy ACCEPT)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

平头哥在等你

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值