1) 重启后生效 
开启: chkconfig iptables on
关闭: chkconfig iptables off 2) 即时生效,重启后失效
开启: service iptables start
关闭: service iptables stop 需要说明的是对于Linux下的其它服务都可以用以上命令执行开启和关闭操作。

开放端口的方法:

方法一:命令行方式
               1. 开放端口命令: /sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
               2.保存:/etc/rc.d/init.d/iptables save
               3.重启服务:/etc/init.d/iptables restart
               4.查看端口是否开放:/sbin/iptables -L -n

方法二:直接编辑/etc/sysconfig/iptables文件
               1.编辑/etc/sysconfig/iptables文件:vi /etc/sysconfig/iptables
                   加入内容并保存:-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
               2.重启服务:/etc/init.d/iptables restart
               3.查看端口是否开放:/sbin/iptables -L -n

但是我用方法一一直保存不上,查阅网上发现直接修改文件不需要iptables save,重启下iptables
重新加载下配置。iptables save
是将当前的iptables写入到/etc/sysconfig/iptables。我不save直接restart也不行,所以还是方法二吧

查询端口是否有进程守护用如下命令grep对应端口,如80为端口号
例:netstat -nalp|grep 80

linux关闭防火墙及开放端口的更多相关文章

  1. [Linux] 关闭防火墙以及开放端口

    一. service iptables stop 临时关闭, chkconfig iptables off完全关闭 service iptables status状态, service iptable ...

  2. Linux关闭防火墙,开放端口

    Centos/redhat系统: 开启防火墙 #systemctl start firewalld.service 停止firewall #systemctl stop firewalld.servi ...

  3. LINUX关闭防火墙、开放特定端口等常用操作

    1. 重启后永久性生效: 开启:chkconfig iptables on 关闭:chkconfig iptables off 2. 即时生效,重启后失效: 开启:service iptables s ...

  4. Linux关闭防火墙、设置端口

    关闭防火墙 1)重启后生效 开启: chkconfig iptables on 关闭: chkconfig iptables off 验证防火墙是否关闭:chkconfig --list |grep ...

  5. linux关闭防火墙

    查看防火墙状态: sudo service iptables status linux关闭防火墙命令: sudo service iptables stop linux启动防火墙命令: sudo se ...

  6. Linux关闭防火墙、SELinux

    使用root权限: Linux关闭防火墙: 1. chkconfig –list|grep iptables 2. chkconfig iptables off 永久关闭防火墙 3. chkconfi ...

  7. Win10系统如何在防火墙里开放端口

    Win10系统如何在防火墙里开放端口(下面傻瓜式教学) 然后怎么做呢?????? 下一步.下一步.下一步.下一步.下一步.下一步.下一步.下一步.下一步.下一步......... 随便起个名字 KO

  8. Linux 防火墙iptables开放端口

    Iptabels是与Linux内核集成的包过滤防火墙系统,几乎所有的linux发行版本都会包含Iptables的功能.如果 Linux 系统连接到因特网或 LAN.服务器或连接 LAN 和因特网的代理 ...

  9. LINUX关闭防火墙(转载)

    (1) 重启后永久性生效: 开启:chkconfig iptables on 关闭:chkconfig iptables off (2) 即时生效,重启后失效: 开启:service iptables ...

随机推荐

  1. Apache rewrite地址重写

    Apache-rewrite+13个经典案例Apache 重写规则的常见应用(rewrite)一:目的 如何用Apache重写规则来解决一些常见的URL重写方法的问题,通过常见的 实例给用户一些使用重 ...

  2. js 获取当前时间 年月日

    var datetime = new Date(); var year = datetime.getFullYear(); var month = datetime.getMonth() + 1 &l ...

  3. [学习笔记]FWT——快速沃尔什变换

    解决涉及子集配凑的卷积问题 一.介绍 1.基本用法 FWT快速沃尔什变换学习笔记 就是解决一类问题: $f[k]=\sum_{i\oplus j=k}a[i]*b[j]$ 基本思想和FFT类似. 首先 ...

  4. Docker的脚本安装

    官方镜像支持 curl -sSL https://get.docker.com/ | sh 国内镜像站 curl -sSL https://get.daocloud.io/docker | sh cu ...

  5. 如何使用Senparc.Weixin SDK 底层的Redis缓存并设置过期时间

    最近在微信第三方平台项目开发中,有一个需求,所有绑定的公众号的回复规则按照主公众号的关键词配置来处理,我的处理思路是获取主公众号配置的关键词回复规则,缓存10分钟,由于需要使用Redis缓存来存储一些 ...

  6. Django(三)框架之第二篇

    https://www.cnblogs.com/haiyan123/p/7717788.html 一.知识点回顾 1.MTV模型 model:模型,和数据库相关的 template:模板,存放html ...

  7. Vue(基础七)_webpack使用工具(下)

    一.前言  1.webpack.config文件配置                                          2.webpack打包css文件                 ...

  8. CodeChef - BLACKCOM 可行性dp转最优化树dp

    https://www.codechef.com/problems/BLACKCOM 题意:一颗5000个黑白结点的树,10W个查询寻找是否存在大小s并且有t和黑节点的子图 一开始就觉得应当是一个树d ...

  9. django新建项目

    命令: django-admin startproject 项目名 pycharm创建: 1. File --> New project --> 左侧选Django --> 右侧填项 ...

  10. xlrd(excel导入mysql数据库)

    一.xlrd模块: python 对 excel 文件进行读操作 1.下载xlrd 并安装 http://pypi.python.org/pypi/xlrd wget https://pypi.pyt ...