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

  1. [zh@localhost ~]$service iptable status

  显示结果:

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

CentOS 6.5关闭防火墙

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

  

CentOS 7.2关闭防火墙

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

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

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

  

检查防火墙的状态:

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

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

  或者

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

  

关闭防火墙:

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

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

  

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

  

Centos 7 firewall 命令:

查看已经开放的端口:

  1. firewall-cmd --list-ports

开启端口

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

命令含义:

–zone #作用域

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

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

重启防火墙

  1. firewall-cmd --reload #重启firewall
  2. systemctl stop firewalld.service #停止firewall
  3. systemctl disable firewalld.service #禁止firewall开机启动
    firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

CentOS 7 以下版本 iptables 命令

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

  1. /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
  2. /sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT
  3. /sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

然后保存:

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

查看打开的端口:

  1. /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. 构建一个基本的前端自动化开发环境 —— 基于 Gulp 的前端集成解决方案(四)

    通过前面几节的准备工作,对于 npm / node / gulp 应该已经有了基本的认识,本节主要介绍如何构建一个基本的前端自动化开发环境. 下面将逐步构建一个可以自动编译 sass 文件.压缩 ja ...

  2. 前端学HTTP之字符集

    前面的话 HTTP报文中可以承载以任何语言表示的内容,就像它能承载图像.影片或任何类型的媒体那样.对HTTP来说,实体主体只是二进制信息的容器而已.为了支持国际性内容,服务器需要告知客户端每个文档的字 ...

  3. [C#] C# 知识回顾 - 序列化

    C# 知识回顾 -  序列化 [博主]反骨仔 [原文地址]http://www.cnblogs.com/liqingwen/p/5902005.html 目录 序列化的含义 通过序列化保存对象数据 众 ...

  4. jQuery幻灯片插件autoPic

    原文地址:Jquery自定义幻灯片插件 插件效果图: 演示地址:autoPic项目地址:autoPic 欢迎批评指正!

  5. Struts2入门(五)——OGNL和标签库

    一.前言 OGNL和标签库的作用,粗暴一点说,就是减少在JSP页面中出现java代码,利于维护. 1.1.OGNL 1.1.1.什么是OGNL? OGNL(Object-Graph Navigatio ...

  6. 微信小程序体验(1):携程酒店机票火车票

    在 12 月 28 日微信公开课上,张小龙对微信小程序的形态进行了阐释,小程序有四个特定:无需安装.触手可及.用完即走.无需卸载. 由于携程这种订酒店.火车票和机票等工具性质非常强的服务,非常符合张小 ...

  7. AndroidStudio — Error:Failed to resolve: junit:junit:4.12错误解决

    原博客:http://blog.csdn.net/u013443865/article/details/50243193 最近使用AndroidStudio出现以下问题: 解决:打开app下的buil ...

  8. 【一起学OpenFoam】01 OpenFoam的优势

    CFD技术发展到今天,已经超过了大半个世纪了,已经涌现出非常多的CFD软件可供人们使用.通用商业CFD软件譬如Fluent.CFX.Star CCM+等在工业上得到了广泛的应用,另外一些专用的软件(如 ...

  9. 前端如何正确选择offer,到底选哪个?

    文章背景:来自于一次线上交流,当时回答感觉比较粗糙,做个阶段性的总结,也分享给其它朋友. 当时的题目是,共2个offer,如何选择: 1. 美团外卖前端 2. 京东深圳前端研发(只有通过邮件,还有收到 ...

  10. Windows 7 上安装Visual Studio 2015 失败解决方案

    安装之前先要看看自己的系统支不支持,具体的可以看:https://www.visualstudio.com/en-us/visual-studio-2015-system-requirements-v ...