我用的是fedora 14

1. 查看iptables 防火墙已经开启的port:/etc/init.d/iptables status

[root@hzswtb2-mpc ~]#/etc/rc.d/init.d/iptables status             或者 service iptables status

Table: filter

Chain INPUT (policy ACCEPT)

num  target     prot opt source               destination        

1    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:3306

Chain FORWARD (policy ACCEPT)

num  target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)

num  target     prot opt source               destination

2. 开启 tcp 8080port

/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

/etc/rc.d/init.d/iptables save  或者 service iptables save #保存配置 
/etc/rc.d/init.d/iptables restart 或者 service iptables restart #重新启动服务

[root@hzswtb2-mpc ~]# /sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

[root@hzswtb2-mpc ~]# /etc/rc.d/init.d/iptables save

iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]

[root@hzswtb2-mpc ~]# /etc/rc.d/init.d/iptables restart

iptables: Flushing firewall rules:                         [  OK  ]

iptables: Setting chains to policy ACCEPT: filter          [  OK  ]

iptables: Unloading modules:                               [  OK  ]

iptables: Applying firewall rules:                         [  OK  ]

[root@hzswtb2-mpc ~]# service iptables status

Table: filter

Chain INPUT (policy ACCEPT)

num  target     prot opt source               destination        

1    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:8080

2    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:3306

3. 删除chain INPUT指定规则1;

[root@hzswtb2-mpc ~]# iptables -D INPUT 1

[root@hzswtb2-mpc ~]# service iptables status       

Table: filter

Chain INPUT (policy ACCEPT)

num  target     prot opt source               destination        

1    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:3306

Chain FORWARD (policy ACCEPT)

num  target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)

num  target     prot opt source               destination

4.Reject 指定port;

[root@hzswtb2-mpc ~]# /sbin/iptables -I INPUT -p tcp --dport 8080 -j REJECT

[root@hzswtb2-mpc ~]# service iptables status                             

Table: filter

Chain INPUT (policy ACCEPT)

num  target     prot opt source               destination        

1    REJECT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:8080 reject-with icmp-port-unreachable

2    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:3306

Chain FORWARD (policy ACCEPT)

num  target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)

num  target     prot opt source               destination

很多其它的规则能够參考

http://www.2cto.com/os/201304/201164.html

Linux下 iptables防火墙 放开相关port 拒绝相关port 及查看已放开port的更多相关文章

  1. linux下iptables防火墙设置

    各位linux的爱好者或者工作跟linux相关的程序员,我们在工作中经常遇到应用服务器端口已经启动, 在网络正常的情况下,访问不到应用程序,这个跟防火墙设置有关 操作步骤 1.检查有没有启动防火墙 s ...

  2. Linux下iptables防火墙用法规则详解

    管理网络流量是系统管理员必需处理的最棘手工作之一,我们必需规定连接系统的用户满足防火墙的传入和传出要求,以最大限度保证系统免受×××.很多用户把 Linux 中的iptables当成一个防火墙,从严格 ...

  3. RedHat Linux下iptables防火墙设置

    一般情况下iptables已经包含在Linux发行版中.运行 # iptables --version 来查看系统是否安装iptables 启动iptables:# service iptables ...

  4. (转载)Linux下IPTABLES防火墙的设定

    (转载)http://www.jefflei.com/post/1760.html 1.iptables防火墙启动和停止 启动iptables防火墙时命令行输入 #service iptables s ...

  5. linux下IPTABLES配置详解 (防火墙命令)

    linux下IPTABLES配置详解 -A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 24000 -j ACCEPT ...

  6. Linux下iptables学习笔记

    Linux下iptables学习笔记 在Centos7版本之后,防火墙应用已经由从前的iptables转变为firewall这款应用了.但是,当今绝大多数的Linux版本(特别是企业中)还是使用的6. ...

  7. 9.Linux之iptables防火墙

    Linux之iptables防火墙 目录 Linux之iptables防火墙 iptables防火墙概述 netfilter和iptables之间的关系 netfilter iptables ipta ...

  8. Linux下系统时间函数、DST等相关问题总结(转)

    Linux下系统时间函数.DST等相关问题总结 下面这个结构体存储了跟时区相关的位移量(offset)以及是否存在DST等信息,根据所在的时区信息,很容易找到系统时间与UTC时间之间的时区偏移,另外根 ...

  9. 详解Linux下iptables中的DNAT与SNAT设置(转)

    详解Linux下iptables中的DNAT与SNAT设置 这篇文章主要介绍了Linux下iptables中的DNAT与SNAT设置,是Linux网络配置中的基础知识,需要的朋友可以参考下   原文连 ...

随机推荐

  1. Python,JAVA中子类的构造函数与父类构造函数的关系

    Python: 子类不重载.覆盖父类的构造函数(子类不自己定义构造函数),则构造子类时会调用父类构造函数 若子类覆盖了父类的构造函数,则构造子类时不执行父类的构造函数,但仍继承了父类,如需调用父类构造 ...

  2. jsoup-1.7.2.jar 包

    org.jsoup.Jsoup; org.jsoup.nodes.Document; org.jsoup.nodes.Element; org.jsoup.select.Elements;

  3. Restrict form resize -- Delphi

    http://www.delphipages.com/forum/showthread.php?t=58391 Hi, How would I restrict a form from being r ...

  4. Spring Bean引用例子

    在Spring,bean可以“访问”对方通过bean配置文件指定相同或不同的引用. 1. Bean在不同的XML文件 如果是在不同XML文件中的bean,可以用一个“ref”标签,“bean”属性引用 ...

  5. Neo4j 使用cypher语言进行查询

    Neo4j是一个Java开发的图数据库,它将结构化数据存储在网络(从数学角度叫做图)上而不是表中.相对于关系数据库来说,图数据库善于处理大量复杂.互连接.低结构化的数据,这些数据变化迅速,需要频繁的查 ...

  6. [Android Pro] android root权限破解分析

    许 多机友新购来的Android机器没有破解过Root权限,无法使用一些需要高权限的软件,以及进行一些高权限的操作,其实破解手机Root权限是比较简 单及安全的,破解Root权限的原理就是在手机的/s ...

  7. 10.线程通信CountDownLatch

    CountDownLatch 1.一个同步的辅助类,在完成一组正在其他线程中执行的操作之前,它允许一个.多个线程去一直等待,用给定的计数.初始化“CountDownLatch”. 由于调用 count ...

  8. 11.线程通信CountDownLatch

    package demo2; import java.util.concurrent.CountDownLatch; /** * Created by liudan on 2017/7/27. */ ...

  9. EF 不允许启动新事务,因为有其他线程正在该会话中运行。

    引起原因:在查询中提交了更改.如在遍历的时候,调用了savechanges(): 解决:把savechange()提到循环外.             IOrderedQueryable<TOH ...

  10. go语言基础之导入包的常用方法

    1.导入包 示例: 法一 package main //导入包,必须使用,否则编译不过 import "fmt" import "os" func main() ...