Centos防火墙的配置
Selinux的三种模式:enforcing,passive,disable
临时更改模式:setengorce 1|0 1:enforcing, 0:passive
[root@Centos7-Server html]#
[root@Centos7-Server html]# setenforce
[root@Centos7-Server html]# getenforce
Permissive
[root@Centos7-Server html]#
[root@Centos7-Server html]# setenforce
[root@Centos7-Server html]# getenforce
Enforcing
[root@Centos7-Server html]#
查询当前seLinux模式:getenforce
[root@Centos7-Server html]#
[root@Centos7-Server html]# getenforce
Enforcing
[root@Centos7-Server html]#
[root@Centos7-Server html]#
selinux 的服务是firewalld。
防火墙的预定义区域:
public:只允许访问本机的某几种服务,如ping,dhcp,ssh等。
block:阻塞所有来访的请求
drop:将所有来访的请求数据包丢弃。
trusted:允许所有的访问请求。
查看默认区域:
[root@Centos7-Server html]# firewall-cmd --get-default-zone
public
[root@Centos7-Server html]#
修改默认区域:
[root@Centos7-Server html]#
[root@Centos7-Server html]# firewall-cmd --set-default-zone=trusted
success
[root@Centos7-Server html]# firewall-cmd --get-default-zone
trusted
[root@Centos7-Server html]#
查看区域详细信息:
[root@Centos7-Server html]#
[root@Centos7-Server html]# firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: ssh dhcpv6-client ftp http
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules: [root@Centos7-Server html]#
向区域中添加服务:
[root@Centos7-Server html]#
[root@Centos7-Server html]# firewall-cmd --zone=public --add-service=dns
success
[root@Centos7-Server html]# firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: ssh dhcpv6-client ftp http dns
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules: [root@Centos7-Server html]#
重新加载防火墙的配置:
[root@Centos7-Server html]#
[root@Centos7-Server html]# firewall-cmd --reload
success
[root@Centos7-Server html]#
[root@Centos7-Server html]#
[root@Centos7-Server html]#
[root@Centos7-Server html]#
[root@Centos7-Server html]# firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: ssh dhcpv6-client
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules: [root@Centos7-Server html]#
永久配置防火墙策略:--permanent这个选项的作用是永久配置防火墙,配置后需要重新加载防火墙配置文件才能生效。
[root@Centos7-Server html]#
[root@Centos7-Server html]# firewall-cmd --permanent --zone=public --add-service=ftpsuccess
[root@Centos7-Server html]# firewall-cmd --permanent --zone=public --add-service=http
success
[root@Centos7-Server html]#
[root@Centos7-Server html]#
[root@Centos7-Server html]#
[root@Centos7-Server html]#
[root@Centos7-Server html]# firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: ssh dhcpv6-client
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules: [root@Centos7-Server html]# firewall-cmd --reload
success
[root@Centos7-Server html]# firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: ssh dhcpv6-client ftp http
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules: [root@Centos7-Server html]#
端口重定向:
服务器将访问端口转换成另一个端口,如:192。168.0.50:5324 --》192.168.0.50:80通过5324端口访问网页。
[root@Centos7-Server ~]# firewall-cmd --permanent --zone=public --add-forward-port=port=:proto=tcp:toport=
success
[root@Centos7-Server ~]#
[root@Centos7-Server ~]#
[root@Centos7-Server ~]#
[root@Centos7-Server ~]#
[root@Centos7-Server ~]# firewall-cmd --reload
success
[root@Centos7-Server ~]#
[root@Centos7-Server ~]#
[root@Centos7-Server ~]#
[root@Centos7-Server ~]#
[root@Centos7-Server ~]#
[root@Centos7-Server ~]#
[root@Centos7-Server ~]# firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: ssh dhcpv6-client ftp http
ports:
protocols:
masquerade: no
forward-ports: port=:proto=tcp:toport=:toaddr=
source-ports:
icmp-blocks:
rich rules: [root@Centos7-Server ~]#
[root@Centos7-Server ~]#
[root@Centos7-Server ~]#
Centos防火墙的配置的更多相关文章
- centos防火墙端口配置
增加防火墙配置,允许8080端口: # vi /etc/sysconfig/iptables 在允许ssh的下面增加一条: -A INPUT -m state --state NEW -m tcp - ...
- CentOS防火墙iptables的配置方法详解
CentOS系统也是基于linux中的它的防火墙其实就是iptables了,下面我来介绍在CentOS防火墙iptables的配置教程,希望此教程对各位朋友会有所帮助. iptables是与Linux ...
- CentOS 7 防火墙端口配置
CentOS 7 防火墙端口配置查看防火墙是否开启systemctl status firewalld 若没有开启则开启systemctl start firewalld 查看所有开启的端口firew ...
- CentOS 7 与老版本CentOS防火墙配置的区别
一.CentOS 7 以下版本防火墙的配置: 1.开放80,22,8080 端口/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT/sbin/ipt ...
- CentOS 6.9下的Setup工具(用于管理服务/防火墙/网络配置/验证服务)
说明:Setup工具套件好像是CentOS下特有的用于管理服务/防火墙/网络配置等,其实就是基于命令行模式界面的GUI工具.唯一特点就是方便. 安装: #安装Setup命令工具 yum -y inst ...
- Centos 7防火墙策略配置指南
Centos 7防火墙策略配置指南 -- 清听凌雪慕忆 @ 目录 1. 开启防火墙 1.1 user切换到root用户 1.2 查看防火墙服务状态 1.3 查看firewall的状态 1.4 启动/关 ...
- 解决宿主机不能访问虚拟机CentOS中的站点 | 更新CentOS防火墙设置开启80端口访问
前阵子在虚拟机上装好了centos6.0,并配好了nginx+php+mysql,但是本机就是无法访问.一直就没去折腾了. 具体情况如下 1.本机能ping通虚拟机 2.虚拟机也能ping通本机 3. ...
- centos防火墙操作
centos防火墙基本操作 #/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT#/sbin/iptables -I INPUT -p tcp -- ...
- Centos下安装配置LAMP(Linux+Apache+MySQL+PHP)
Centos下安装配置LAMP(Linux+Apache+MySQL+PHP) 关于LAMP的各种知识,还请大家自行百度谷歌,在这里就不详细的介绍了,今天主要是介绍一下在Centos下安装,搭建一 ...
随机推荐
- Jms学习篇二:ActiveMQ
ActiveMQ 是Apache出品,最流行的,能力强劲的开源消息总线 安装 1>下载:到http://activemq.apache.org/download.html 下载最新版本, 解压a ...
- css中的单位和css中的颜色表示方法
css中颜色的表示方式: 图片来源http://www.w3school.com.cn
- 【代码笔记】Java学习一阶段总结
写笔记需要打开eclipse写 哈哈哈哈,不然写什么都屡不清了 ……还需要打开API说明文档. JFrame 窗体组件. JFrame里面常用的函数: setSize 设置窗体大小 setDefaul ...
- Kafka监控利器
开发过程中,kafka几乎是标配的Mq,如果有一个kafka的监控助手,哪就更完美了,常用的kafka监控工具有 KafkaOffsetMonitor .Kafka Manager.Capillary ...
- OAuth2.0 入门与进阶
一.基础知识 1.OAuth产生背景 很多网站.APP 弱化甚至没有搭建自己的账号体系,而是直接使用社会化登录的方式,这样不仅免去了用户注册账号的麻烦.还可以获取用户的好友关系来增强自身的社交功能. ...
- arcengine自己做一个工具Tool放到工具箱中
// Copyright 2010 ESRI // // All rights reserved under the copyright laws of the United States // an ...
- HTML基础内容(持续更新...)
1.<!DOCTYPE html>声明有助于浏览器中正确显示网页 HTML5<!DOCTYPE html>HTML 4.01<!DOCTYPE HTML PUBLIC & ...
- verilog 三段式状态机的技巧
三段式代码多,但是有时钟同步,延时少,组合逻辑跟时序逻辑分开并行出错少. (1)同步状态转移 (2)当前状态判断接下来的状态 (3)动作输出 如果程序复杂可以不止三个always .always ...
- NO.010-2018.02.15《上邪》两汉:佚名
上邪_古诗文网 上邪 两汉:佚名 上邪,我欲与君相知,长命无绝衰.上天呀!我渴望与你相知相惜,长存此心永不褪减.上邪(yé)!:天啊!.上,指天.邪,语气助词,表示感叹. 相知:相爱.命:古与“令”字 ...
- 设计模式——抽象工厂模式(AbstractFactoryPattern)
抽象工厂模式(AbstractFactory):提供一个创建一系列相关或相互依赖对象的接口,而无需指定他们具体的类. UML图: IFactory: package com.cnblog.clarck ...