CentOS6.5查看防火墙的状态:

[zh@localhost ~]$service iptable status

  显示结果:

[zh@localhost ~]$service iptable status
Redirecting to /bin/systemctl status iptable.service
● iptable.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead) --表示防火墙已经关闭

CentOS 6.5关闭防火墙

[root@localhost ~]#servcie iptables stop                     --临时关闭防火墙
[root@localhost ~]#chkconfig iptables off --永久关闭防火墙

  

CentOS 7.2关闭防火墙

CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。

firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

[root@localhost ~]#firewall-cmd --state
not running

  

检查防火墙的状态:

从centos7开始使用systemctl来管理服务和程序,包括了service和chkconfig。

[root@localhost ~]#systemctl list-unit-files|grep firewalld.service            --防火墙处于关闭状态
firewalld.service disabled

  或者

[root@localhost ~]#systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)

  

关闭防火墙:

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动

[root@localhost ~]#systemctl stop firewalld.service
[root@localhost ~]#systemctl disable firewalld.service

  

启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service;echo $?
查看已启动的服务列表:systemctl list-unit-files|grep enabled

  

Centos 7 firewall 命令:

查看已经开放的端口:

firewall-cmd --list-ports

开启端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

命令含义:

–zone #作用域

–add-port=80/tcp #添加端口,格式为:端口/通讯协议

–permanent #永久生效,没有此参数重启后失效

重启防火墙

firewall-cmd --reload #重启firewall
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动

firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

CentOS 7 以下版本 iptables 命令

如要开放80,22,8080 端口,输入以下命令即可

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

然后保存:

/etc/rc.d/init.d/iptables save

查看打开的端口:

/etc/init.d/iptables status

关闭防火墙 
1) 永久性生效,重启后不会复原

开启: chkconfig iptables on

关闭: chkconfig iptables off

2) 即时生效,重启后复原

开启: service iptables start

关闭: service iptables stop

查看防火墙状态: service iptables status

下面说下CentOS7和6的默认防火墙的区别

CentOS 7默认使用的是firewall作为防火墙,使用iptables必须重新设置一下

1、直接关闭防火墙

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall开机启动

2、设置 iptables service

yum -y install iptables-services

如果要修改防火墙配置,如增加防火墙端口3306

vi /etc/sysconfig/iptables

增加规则

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

保存退出后

systemctl restart iptables.service #重启防火墙使配置生效

systemctl enable iptables.service #设置防火墙开机启动

最后重启系统使设置生效即可。

systemctl start iptables.service #打开防火墙

systemctl stop iptables.service #关闭防火墙

解决主机不能访问虚拟机CentOS中的站点

前阵子在虚拟机上装好了CentOS6.2,并配好了apache+php+mysql,但是本机就是无法访问。一直就没去折腾了。 
 
具体情况如下 
1. 本机能ping通虚拟机 
2. 虚拟机也能ping通本机 
3.虚拟机能访问自己的web 
4.本机无法访问虚拟机的web 
 
后来发现是防火墙将80端口屏蔽了的缘故。 
 
检查是不是服务器的80端口被防火墙堵了,可以通过命令:telnet server_ip 80 来测试。 
 
 
 
解决方法如下: 

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

然后保存: 

/etc/rc.d/init.d/iptables save

重启防火墙 

/etc/init.d/iptables restart

 
 
CentOS防火墙的关闭,关闭其服务即可: 
查看CentOS防火墙信息:/etc/init.d/iptables status 
关闭CentOS防火墙服务:/etc/init.d/iptables stop 

  

centos6和centos7防火墙的关闭的更多相关文章

  1. 详解centos6和centos7防火墙的关闭

    http://www.jb51.net/article/101576.htm http://www.myhack58.com/Article/48/66/2013/37314.htm http://w ...

  2. 详解centos6和centos7防火墙

    CentOS6.5查看防火墙的状态: ? 1 [zh@localhost ~]$service iptable status 显示结果: ? 1 2 3 4 5 6 7 8 9 [zh@localho ...

  3. Centos6、Centos7防火墙基本操作整理

    Centos7: 查看防火墙状态: firewall-cmd --state 开启防火墙: systemctl start firewalld.service 关闭防火墙(重启失效): systemc ...

  4. Centos6与Centos7防火墙设置与端口开放的方法

    Centos升级到7之后,内置的防火墙已经从iptables变成了firewalld.所以,端口的开启还是要从两种情况来说明的,即iptables和firewalld.更多关于CentOs防火墙的最新 ...

  5. centos7防火墙的关闭

    从centos7开始使用systemctl来管理服务和程序,包括了service和chkconfig. #systemctl list-unit-files|grep firewalld.servic ...

  6. centos6和centos7的防火墙基本命令

    一.centos6: 1.firewall的基本启动/停止/重启命令 $查看防火墙状态: service iptables status (/etc/init.d/iptables status) $ ...

  7. CentOS7防火墙firewalld 和 CentOS6防火墙iptables的一些配置命令

    CentOS7 防火墙 一.防火墙的开启.关闭.禁用.查看状态命令 (1)启动防火墙:systemctl start firewalld (2)关闭防火墙:systemctl stop firewal ...

  8. CentOs7 使用iptables防火墙开启关闭端口

    CentOs7 使用iptables防火墙开启关闭端口   # 0x01介绍 iptables命令是Linux上常用的防火墙软件,是netfilter项目的一部分iptables文件设置路径:命令:v ...

  9. Centos7防火墙和SELinux的开启和关闭

    在虚拟机里面开启多个服务,对应多个端口,在防火墙开启的情况下,就要对外开放端口,这样客户端才能正常访问,但比较繁琐,关闭更直接点. 防火墙 临时关闭防火墙 systemctl stop firewal ...

随机推荐

  1. Sublime Text 3中文乱码解决方法以及安装包管理器方法

    一般出现乱码是因为文本采用了GBK编码格式,Sublime Text默认不支持GBK编码. 安装包管理器 简单安装 使用Ctrl+`快捷键或者通过View->Show Console菜单打开命令 ...

  2. JS里面Data日期格式转换

    var format = function(time, format){     var t = new Date(time);     var tf = function(i){return (i  ...

  3. MSDN文档篇

    很多人网上下载3~10G不等的MSDN文档,发现,下载完成了不会用 很多人每次都得在线下载文档,手上万千PC,都重新下载不是得疯了? so==> 先看几张图 推荐一个工具:https://vsh ...

  4. SQL:指定名称查不到数据的衍伸~空格 换行符 回车符的批量处理

    异常处理汇总-数据库系列  http://www.cnblogs.com/dunitian/p/4522990.html 先看看啥情况 复制查询到的数据,粘贴一下看看啥情况 那就批量处理一下~ 就这样 ...

  5. JavaScript Date对象

    本篇主要介绍 Date 日期和时间对象的操作. 目录 1. 介绍:阐述 Date 对象. 2. 构造函数:介绍 Date 对象的构造函数new Date()几种方式. 3. 实例方法:介绍 Date ...

  6. 【.net 深呼吸】启动一个进程并实时获取状态信息

    地球人和火星人都知道,Process类既可以获取正在运行的进程,也可以启动一个新的进程.在79.77%应用场合,我们只需要让目标进程顺利启动就完事了,至于它执行了啥,有没有出错,啥时候退出就不管了. ...

  7. javaScript的原型继承与多态性

    1.prototype 我们可以简单的把prototype看做是一个模版,新创建的自定义对象都是这个模版(prototype)的一个拷贝 (实际上不是拷贝而是链接,只不过这种链接是不可见,给人们的感觉 ...

  8. 关于面试题 Array.indexof() 方法的实现及思考

    这是我在面试大公司时碰到的一个笔试题,当时自己云里雾里的胡写了一番,回头也曾思考过,最终没实现也就不了了之了. 昨天看到有网友说面试中也碰到过这个问题,我就重新思考了这个问题的实现方法. 对于想进大公 ...

  9. CRL快速开发框架系列教程十三(嵌套查询)

    本系列目录 CRL快速开发框架系列教程一(Code First数据表不需再关心) CRL快速开发框架系列教程二(基于Lambda表达式查询) CRL快速开发框架系列教程三(更新数据) CRL快速开发框 ...

  10. 【C#附源码】数据库文档生成工具支持(Excel+Html)

    [2015] 很多时候,我们在生成数据库文档时,使用某些工具,可效果总不理想,不是内容不详细,就是表现效果一般般.很多还是word.html的.看着真是别扭.本人习惯用Excel,所以闲暇时,就简单的 ...