iptables 必须先拒绝所有,在允许

<pre name="code" class="html">[root@wx02 ~]# cat /etc/sysconfig/iptables
# Generated by iptables-save v1.4.7 on Tue Sep 20 11:18:45 2016
*filter
:INPUT ACCEPT [100:5792]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [104:8990]
COMMIT
# Completed on Tue Sep 20 11:18:45 2016


先允许,在拒绝
iptables -I INPUT -s 115.236.6.6 -p tcp --dport 22 -j ACCEPT
iptables -I INPUT -p tcp --dport 22 -j DROP  
 
 
 # service iptables save    
3.重启防火墙    
#service iptables restart   


/**先拒绝所有,在允许

[root@wx02 ~]# cat /etc/sysconfig/iptables
# Generated by iptables-save v1.4.7 on Tue Sep 20 11:39:10 2016
*filter
:INPUT ACCEPT [293:18238]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [231:19319]
-A INPUT -s 115.236.6.6/32 -p tcp -m tcp --dport 22 -j ACCEPT 
-A INPUT -p tcp -m tcp --dport 22 -j DROP 
COMMIT
# Completed on Tue Sep 20 11:39:10 2016


[root@wx02 ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  115.236.6.6       anywhere            tcp dpt:ssh 
DROP       tcp  --  anywhere             anywhere            tcp dpt:ssh 

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
[root@wx02 ~]# 


 

转载于:https://www.cnblogs.com/zhaoyangjian724/p/6199183.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值