centos6和centos7防火墙的关闭
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中的站点
1. 本机能ping通虚拟机2. 虚拟机也能ping通本机3.虚拟机能访问自己的web4.本机无法访问虚拟机的web
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables restart
查看CentOS防火墙信息:/etc/init.d/iptables status关闭CentOS防火墙服务:/etc/init.d/iptables stop
centos6和centos7防火墙的关闭的更多相关文章
- 详解centos6和centos7防火墙的关闭
http://www.jb51.net/article/101576.htm http://www.myhack58.com/Article/48/66/2013/37314.htm http://w ...
- 详解centos6和centos7防火墙
CentOS6.5查看防火墙的状态: ? 1 [zh@localhost ~]$service iptable status 显示结果: ? 1 2 3 4 5 6 7 8 9 [zh@localho ...
- Centos6、Centos7防火墙基本操作整理
Centos7: 查看防火墙状态: firewall-cmd --state 开启防火墙: systemctl start firewalld.service 关闭防火墙(重启失效): systemc ...
- Centos6与Centos7防火墙设置与端口开放的方法
Centos升级到7之后,内置的防火墙已经从iptables变成了firewalld.所以,端口的开启还是要从两种情况来说明的,即iptables和firewalld.更多关于CentOs防火墙的最新 ...
- centos7防火墙的关闭
从centos7开始使用systemctl来管理服务和程序,包括了service和chkconfig. #systemctl list-unit-files|grep firewalld.servic ...
- centos6和centos7的防火墙基本命令
一.centos6: 1.firewall的基本启动/停止/重启命令 $查看防火墙状态: service iptables status (/etc/init.d/iptables status) $ ...
- CentOS7防火墙firewalld 和 CentOS6防火墙iptables的一些配置命令
CentOS7 防火墙 一.防火墙的开启.关闭.禁用.查看状态命令 (1)启动防火墙:systemctl start firewalld (2)关闭防火墙:systemctl stop firewal ...
- CentOs7 使用iptables防火墙开启关闭端口
CentOs7 使用iptables防火墙开启关闭端口 # 0x01介绍 iptables命令是Linux上常用的防火墙软件,是netfilter项目的一部分iptables文件设置路径:命令:v ...
- Centos7防火墙和SELinux的开启和关闭
在虚拟机里面开启多个服务,对应多个端口,在防火墙开启的情况下,就要对外开放端口,这样客户端才能正常访问,但比较繁琐,关闭更直接点. 防火墙 临时关闭防火墙 systemctl stop firewal ...
随机推荐
- Jade模板引擎让你飞
写在前面:现在jade改名成pug了 一.安装 npm install jade 二.基本使用 1.简单使用 p hello jade! 渲染后: <p>hello jade!</p ...
- ExtJS 4.2 Grid组件的单元格合并
ExtJS 4.2 Grid组件本身并没有提供单元格合并功能,需要自己实现这个功能. 目录 1. 原理 2. 多列合并 3. 代码与在线演示 1. 原理 1.1 HTML代码分析 首先创建一个Grid ...
- 学习ASP.NET Core,怎能不了解请求处理管道[2]: 服务器在管道中的“龙头”地位
ASP.NET Core管道由注册的服务器和一系列中间件构成.我们在上一篇中深入剖析了中间件,现在我们来了解一下服务器.服务器是ASP .NET Core管道的第一个节点,它负责完整请求的监听和接收, ...
- 从零开始编写自己的C#框架(26)——小结
一直想写个总结,不过实在太忙了,所以一直拖啊拖啊,拖到现在,不过也好,有了这段时间的沉淀,发现自己又有了小小的进步.哈哈...... 原想框架开发的相关开发步骤.文档.代码.功能.部署等都简单的讲过了 ...
- 页面布局class常见命名规范
头:header 内容:content/container 尾:footer 导航:nav 侧栏:sidebar 栏目:column 页面外围控制整体布局宽度:wrapper 左右中:left rig ...
- svn常用命令
1.新建版本库 [root@localhost repos]# mkdir -p project [root@localhost repos]# svnadmin create project [ro ...
- 如何使用SHOW WARNINGS?
1.show warnings:显示上一个语句的错误.警告以及注意.如图:
- 为什么你SQL Server的数据库文件的Date modified没有变化呢?
在SQL Server数据库中,数据文件与事务日志文件的修改日期(Date Modified)是会变化的,但是有时候你会发现你的数据文件或日志文件的修改日期(Date Modified)几个月甚至是半 ...
- 跨平台的 .NET 运行环境 Mono 3.2 新特性
Mono 3.2 发布了,对 Mono 3.0 和 2.10 版本的支持不再继续,而且这两个分支也不再提供 bug 修复更新. Mono 3.2 主要新特性: LLVM 更新到 3.2 版本,带来更多 ...
- Xamarin.Android之使用百度地图起始篇
一.前言 如今跨平台开发层出不穷,而对于.NET而言时下最流行的当然还是Xamarin,不仅仅能够让我们在熟悉的Vs下利用C#开发,在对原生态类库的支持方面也有着非常的好支持,今天我们将会以百度地图类 ...