zoukankan      html  css  js  c++  java
  • iptables 顺序

    -A INPUT -s 115.236.6.6/32 -p udp -m udp --dport 111 -j ACCEPT
    -A INPUT -s 10.175.197.98/32 -p udp -m udp --dport 111 -j ACCEPT
    -A INPUT -s 10.171.254.221/32 -p udp -m udp --dport 111 -j ACCEPT
    -A INPUT -p udp -m udp --dport 111 -j DROP
    
    -A INPUT -s 10.175.197.98/32 -p udp -m udp --dport 111 -j ACCEPT
    -A INPUT -s 115.236.6.6/32 -p tcp -m tcp --dport 111 -j ACCEPT
    -A INPUT -s 10.171.254.221/32 -p tcp -m tcp --dport 111 -j ACCEPT
    -A INPUT -p tcp -m tcp --dport 111 -j DROP
    
    -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
    -A INPUT -s 121.42.0.15/32 -j DROP
    
       Insert one or more rules in the selected chain as the given rule number.  So, if the rule number is 1, 
       
       the rule or rules are inserted at the head of the chain.  This is also the default if
       no rule number is specified.
    		
    插入chain 规则说明;
    
    插入一个或者多个规则在选择的chain 作为给定的规则number
    
    因此 如果规则number 是1, rule和rules 是被插入到chain的头部,这也是默认的如果没有规则number 被指定
    [root@nfs01 ~]# cat /etc/sysconfig/iptables
    # Generated by iptables-save v1.4.7 on Tue Sep 20 11:03:42 2016
    *filter
    :INPUT ACCEPT [1032:58291]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [1452:2612203]
    COMMIT
    # Completed on Tue Sep 20 11:03:42 2016
    
    		
    	切换到root用户  
    1、在tcp协议中,禁止所有的ip访问本机的22端口。  
    iptables -I INPUT -p tcp --dport 22 -j DROP  
      
    iptables -I INPUT -s 115.236.6.6 -p tcp --dport 22 -j ACCEPT 
    
    iptables -I INPUT -p tcp --dport 111 -j DROP 		  
    iptables -I INPUT -s 115.236.6.6 -p tcp --dport 111 -j ACCEPT 
    iptables -I INPUT -s 10.175.197.98 -p tcp --dport 111 -j ACCEPT
    iptables -I INPUT -s 10.171.254.221 -p tcp --dport 111 -j ACCEPT	
    
    iptables -I INPUT -p udp --dport 111 -j DROP 		  
    iptables -I INPUT -s 115.236.6.6 -p udp --dport 111 -j ACCEPT 
    iptables -I INPUT -s 10.175.197.98 -p udp --dport 111 -j ACCEPT
    iptables -I INPUT -s 10.171.254.221 -p udp --dport 111 -j ACCEPT
    		
    
    # service iptables save  
    3.重启防火墙  
    #service iptables restart 		
    
    
    api01:/nfs01/zjprd/contract> telnet 10.171.250.68 111
    Trying 10.171.250.68...
    Connected to 10.171.250.68.
    Escape character is '^]'.
    
    
    [root@nfs01 ~]# cat a1.sh
    iptables -I INPUT -p tcp --dport 22 -j DROP  
    iptables -I INPUT -s 115.236.160.82 -p tcp --dport 22 -j ACCEPT 
    iptables -I INPUT -p tcp --dport 111 -j DROP 		  
    iptables -I INPUT -s 115.236.160.82 -p tcp --dport 111 -j ACCEPT 
    iptables -I INPUT -s 10.175.197.98 -p tcp --dport 111 -j ACCEPT
    iptables -I INPUT -s 10.171.254.221 -p tcp --dport 111 -j ACCEPT	
    iptables -I INPUT -p udp --dport 111 -j DROP 		  
    iptables -I INPUT -s 115.236.160.82 -p udp --dport 111 -j ACCEPT 
    iptables -I INPUT -s 10.175.197.98 -p udp --dport 111 -j ACCEPT
    iptables -I INPUT -s 10.171.254.221 -p udp --dport 111 -j ACCEPT
    
    
    [root@nfs01 ~]# 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]
    -A INPUT -s 10.171.254.221/32 -p udp -m udp --dport 111 -j ACCEPT 
    -A INPUT -s 10.175.197.98/32 -p udp -m udp --dport 111 -j ACCEPT 
    -A INPUT -s 115.236.6.6/32 -p udp -m udp --dport 111 -j ACCEPT 
    -A INPUT -p udp -m udp --dport 111 -j DROP 
    -A INPUT -s 10.171.254.221/32 -p tcp -m tcp --dport 111 -j ACCEPT 
    -A INPUT -s 10.175.197.98/32 -p tcp -m tcp --dport 111 -j ACCEPT 
    -A INPUT -s 115.236.6.6/32 -p tcp -m tcp --dport 111 -j ACCEPT 
    -A INPUT -p tcp -m tcp --dport 111 -j DROP 
    -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:18:45 2016
    
    
    正常顺序是先允许 ,后拒绝所有

  • 相关阅读:
    Maven的安装、配置及使用入门+maven安装报错:JAVA_HOME【申明:来源于网络】
    Android总结之json解析(FastJson Gson 对比)[申明:来源于网络]
    JSON.stringify 语法实例讲解+easyui data-options属性+expires【申明:来源于网络】
    第一次的博客(写一点关于今天的数据库学习吧)
    WPF 捕捉全局异常
    C#跨线程操作UI
    C#通过盘符获取剩余空间
    C#字符串转UNICODE
    C#生成随机数
    Core引用Jquery文件
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199184.html
Copyright © 2011-2022 走看看