Linux下 iptables防火墙 放开相关port 拒绝相关port 及查看已放开port
我用的是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
[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
很多其它的规则能够參考
Linux下 iptables防火墙 放开相关port 拒绝相关port 及查看已放开port的更多相关文章
- linux下iptables防火墙设置
各位linux的爱好者或者工作跟linux相关的程序员,我们在工作中经常遇到应用服务器端口已经启动, 在网络正常的情况下,访问不到应用程序,这个跟防火墙设置有关 操作步骤 1.检查有没有启动防火墙 s ...
- Linux下iptables防火墙用法规则详解
管理网络流量是系统管理员必需处理的最棘手工作之一,我们必需规定连接系统的用户满足防火墙的传入和传出要求,以最大限度保证系统免受×××.很多用户把 Linux 中的iptables当成一个防火墙,从严格 ...
- RedHat Linux下iptables防火墙设置
一般情况下iptables已经包含在Linux发行版中.运行 # iptables --version 来查看系统是否安装iptables 启动iptables:# service iptables ...
- (转载)Linux下IPTABLES防火墙的设定
(转载)http://www.jefflei.com/post/1760.html 1.iptables防火墙启动和停止 启动iptables防火墙时命令行输入 #service iptables s ...
- linux下IPTABLES配置详解 (防火墙命令)
linux下IPTABLES配置详解 -A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 24000 -j ACCEPT ...
- Linux下iptables学习笔记
Linux下iptables学习笔记 在Centos7版本之后,防火墙应用已经由从前的iptables转变为firewall这款应用了.但是,当今绝大多数的Linux版本(特别是企业中)还是使用的6. ...
- 9.Linux之iptables防火墙
Linux之iptables防火墙 目录 Linux之iptables防火墙 iptables防火墙概述 netfilter和iptables之间的关系 netfilter iptables ipta ...
- Linux下系统时间函数、DST等相关问题总结(转)
Linux下系统时间函数.DST等相关问题总结 下面这个结构体存储了跟时区相关的位移量(offset)以及是否存在DST等信息,根据所在的时区信息,很容易找到系统时间与UTC时间之间的时区偏移,另外根 ...
- 详解Linux下iptables中的DNAT与SNAT设置(转)
详解Linux下iptables中的DNAT与SNAT设置 这篇文章主要介绍了Linux下iptables中的DNAT与SNAT设置,是Linux网络配置中的基础知识,需要的朋友可以参考下 原文连 ...
随机推荐
- Linux下路由表调试工具traceroute
在做静态路由表或者路由表分配时,比较直接的调试工具是traceroute,可以跟踪访问一个IP所到达的路由层级,从而知道经过哪些链路. 参考: http://man.linuxde.net/trace ...
- 解决数据库 Table 'content_tags' is marked as crashed and should be repaired 表损坏问题
今天突然网站TAG页面打不开了,打开debug,发现提示 Table 'content_tags' is marked as crashed and should be repaired 这样的错误 ...
- Unity 网络请求(1)
using UnityEngine; using System.Collections; public class Scene1 : MonoBehaviour { //下载图片的容器 private ...
- Ubuntu 11.04安装GCC 4.6.1
首先下载相应的源代码:ftp://ftp.dti.ad.jp/pub/lang/gcc/releases/gcc-4.6.1/#下载 gcc-4.6.1.tar.bz2 ftp://ftp.dti.a ...
- mysql -h localhost和mysql -h 127.0.0.1的区别
今天早上同事说MySQL root账号登录不上了.我试了一下 #mysql -u root -p 提示”Access denied for user ‘root’@’localhost’ (using ...
- 使用Vue.js和Axios从第三方API获取数据 — SitePoint
更多的往往不是,建立你的JavaScript应用程序时,你会想把数据从远程源或消耗一个[ API ](https:/ /恩.维基百科.org /维基/ application_programming_ ...
- redis.conf配置解释
daemonize:如果需要在后台运行,把该项改为yespidfile:配置多个pid的地址,默认在/var/run/redis.pidbind:绑定ip,设置后只接受来自该ip的请求port:监听端 ...
- linux下启动tomcat出现“This file is needed to run this program ”
使用sh startup.sh启动tomcat 出现This file is needed to run this program 原因.sh文件都不是可执行文件,于是找到命令: chmod +x * ...
- 【mybatis】mybatis查询发生条件传入值但是查询并没有这个条件的查询,Integer类型查询条件需要注意事项
有下面这样一个查询: 下面标紫色的查询条件,type的类型为Integer <select id="findDealerInfo" parameterType="c ...
- Appium+python自动化13-native和webview切换
前言 现在大部分app都是混合式的native+webview,对应native上的元素通过uiautomatorviewer很容易定位到,webview上的元素就无法识别了. 一.识别webview ...