-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 正常顺序是先允许 ,后拒绝所有

iptables 顺序的更多相关文章

  1. 【提醒】使用 iptables 时,特别注意 规则的顺序

    在 centos 上安装 redis 服务器,很快就搞定了,服务器上使用 redis-cl 测试都没有问题了. 但到宿主机上测试,怎么测试都不通过,关键是:关闭了 centos 的 Iptables ...

  2. Iptables规则执行顺序详解

      1.The first is the mangle table which is responsible for the alteration of quality of service bits ...

  3. iptables配置顺序-两条规则会忽略后边的

    oracle在centos本机能够正常访问,关闭防火墙也能够远程访问,但是一旦开启防火墙则不能远程访问 尝试添加规则iptables -A INPUT -m state --state NEW -m ...

  4. CentOS7安装iptables防火墙

    CentOS7默认的防火墙不是iptables,而是firewalle. 安装iptable iptable-service #先检查是否安装了iptables service iptables st ...

  5. linux iptables常用命令之配置生产环境iptables及优化

    在了解iptables的详细原理之前,我们先来看下如何使用iptables,以终为始,有可能会让你对iptables了解更深 所以接下来我们以配置一个生产环境下的iptables为例来讲讲它的常用命令 ...

  6. Linux iptables配置错误导致ORA-12535 & ORA-12170

    实验环境:       操作系统  : Red Hat Enterprise Linux Server release 5.7 (Tikanga)       数据库版本: Oracle Databa ...

  7. iptables详解

    Netfilter包含有三种表,三种表下共包含有五种链,链下面包含各种规则.即表包含若干链,链包含若干规则.  (一)三种表为:filter   nat  mangle 1.filter:处理与本机有 ...

  8. (一)洞悉linux下的Netfilter&iptables:什么是Netfilter?

    转自:http://blog.chinaunix.net/uid-23069658-id-3160506.html 本人研究linux的防火墙系统也有一段时间了,由于近来涉及到的工作比较纷杂,久而久之 ...

  9. 使用nginx和iptables做访问权限控制(IP和MAC)

    之前配置的服务器,相当于对整个内网都是公开的 而且,除了可以通过80端口的nginx来间接访问各项服务,也可以绕过nginx,直接ip地址加端口访问对应服务 这是不对的啊,所以我们要做一些限制 因为只 ...

随机推荐

  1. android SimpleCursorAdapter的使用

    String[] fields=new String[]{"foodname","price","taste","stuff&qu ...

  2. POJ 2886 Who Gets the Most Candies? 线段树。。还有方向感

    这道题不仅仅是在考察线段树,还他妹的在考察一个人的方向感.... 和线段树有关的那几个函数写了一遍就对了,连改都没改,一直在转圈的问题的出错.... 题意:从第K个同学开始,若K的数字为正 则往右转, ...

  3. 【KMP】Cyclic Nacklace

    KMP算法 next[]深入了解,做到这题才真正明白next[]的用法,希望后面的题目能理解的更深刻. Problem Description CC always becomes very depre ...

  4. linux 切换用户之后变成-bash-x.x$的解决方法

    我们平时在linux下切换用户后命令行为什么会变成-bash-3.2$呢,我们来分析一下,这就是跟linux的机制有关联了,因为在linux下每次通过useradd创建新的用户时,都会将所有的配置文件 ...

  5. python游戏编程——跟13岁儿童学编程

    python爬虫基本告一段落,琢磨搞点其他的,正好在网上看到一个帖子,一个外国13岁小朋友用python写的下棋程序,内容详细,也有意思,拿来练手. 13岁啊.. 我这年纪还在敲 dir啥的吧 想到原 ...

  6. PHP magic_quotes_gpc

    大多的PHP程序,都有这样的逻辑: 如果发现php.ini配置为不给GPC变量自动添加转义斜线,则PHP自动为GPC添加转义斜线 但是事实上,这是错误的,因为它改变了GPC变量原来的值. 有这个遗留习 ...

  7. ViewDragHelper详解

    2013年谷歌i/o大会上介绍了两个新的layout: SlidingPaneLayout和DrawerLayout,现在这俩个类被广泛的运用,其实研究他们的源码你会发现这两个类都运用了ViewDra ...

  8. 配置NFS服务

    1. NFS配置,需要安装哪些包?nfs-utils  和 rpcbind2. 如果不开启rpcbind服务,就启动NFS,会怎么样?如果不开启rpcbind服务,会报错:rpc.nfsd: writ ...

  9. Android推送等耗电原因剖析

    原文链接:http://www.jianshu.com/p/584707554ed7 Android手机有两个处理器,一个是Application Processor(AP)基于ARM处理器,主要运行 ...

  10. 配置 VS 2015 开发跨平台手机应用

    为了使用 VS 2015 开发跨平台手机应用,VS 2015 装了很多次,遇到了很多坑,才终于弄明白怎样配置才能正常使用C#开发手机应用,现把步骤分享给大家,以免大家少走弯路. 运行环境: Windo ...