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防火墙的配置的更多相关文章

  1. centos防火墙端口配置

    增加防火墙配置,允许8080端口: # vi /etc/sysconfig/iptables 在允许ssh的下面增加一条: -A INPUT -m state --state NEW -m tcp - ...

  2. CentOS防火墙iptables的配置方法详解

    CentOS系统也是基于linux中的它的防火墙其实就是iptables了,下面我来介绍在CentOS防火墙iptables的配置教程,希望此教程对各位朋友会有所帮助. iptables是与Linux ...

  3. CentOS 7 防火墙端口配置

    CentOS 7 防火墙端口配置查看防火墙是否开启systemctl status firewalld 若没有开启则开启systemctl start firewalld 查看所有开启的端口firew ...

  4. CentOS 7 与老版本CentOS防火墙配置的区别

    一.CentOS 7 以下版本防火墙的配置: 1.开放80,22,8080 端口/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT/sbin/ipt ...

  5. CentOS 6.9下的Setup工具(用于管理服务/防火墙/网络配置/验证服务)

    说明:Setup工具套件好像是CentOS下特有的用于管理服务/防火墙/网络配置等,其实就是基于命令行模式界面的GUI工具.唯一特点就是方便. 安装: #安装Setup命令工具 yum -y inst ...

  6. Centos 7防火墙策略配置指南

    Centos 7防火墙策略配置指南 -- 清听凌雪慕忆 @ 目录 1. 开启防火墙 1.1 user切换到root用户 1.2 查看防火墙服务状态 1.3 查看firewall的状态 1.4 启动/关 ...

  7. 解决宿主机不能访问虚拟机CentOS中的站点 | 更新CentOS防火墙设置开启80端口访问

    前阵子在虚拟机上装好了centos6.0,并配好了nginx+php+mysql,但是本机就是无法访问.一直就没去折腾了. 具体情况如下 1.本机能ping通虚拟机 2.虚拟机也能ping通本机 3. ...

  8. centos防火墙操作

    centos防火墙基本操作 #/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT#/sbin/iptables -I INPUT -p tcp -- ...

  9. Centos下安装配置LAMP(Linux+Apache+MySQL+PHP)

    Centos下安装配置LAMP(Linux+Apache+MySQL+PHP)   关于LAMP的各种知识,还请大家自行百度谷歌,在这里就不详细的介绍了,今天主要是介绍一下在Centos下安装,搭建一 ...

随机推荐

  1. eclipse的应用和整理

    1如何在eclipse中获取动态项目的绝对路径 1.鼠标选中项目,右击菜单,选择properties2.出来弹出框,选择resource,location的值就是你想要的项目绝对路径 JSP中获得当前 ...

  2. Cass和ArcGIS交换

    南方cass图形为CAD,把CAD图形转换成arcgis没有任何问题,到属性有问题,cass存放数据是放在CAD扩展XDATA中,和 arcgis导入导出CAD标准扩展属性不一样,只能二次开发使用,c ...

  3. jmeter简单录制

    JMeter介绍 1.JMeter,一个100%的纯Java桌面应用,它是Apache组织的开放源代码项目,它是功能和性能测试的工具.JMeter可以用于测试静态或者动态资源的性能(文件.Servle ...

  4. SVN学习——简单入门之创建仓库、导入、检出(一)

    从刚刚参加工作就开始使用svn,清晰的记得那年师姐比较生气的来找我:“你怎么又不更新就提交代码了,把我写的都给覆盖掉了”,哈哈~ 虽然一直在用svn,不过在日常工作中主要用到的是简单的操作,而且大多数 ...

  5. javascript面向对象的写法01

    类和对象 其他面向对象的语言类的语法是内置的,自然而然的事.javascript中有对象,但没有类的语法,类的实现需要模拟出来. 只需要把对象想成一个容器,里面存放一些属性或方法,把类想象成一个对象的 ...

  6. java:反射机制

    Java反射机制及IoC原理:https://www.cnblogs.com/Eason-S/p/5851078.html Java中反射机制详解:https://www.cnblogs.com/wh ...

  7. Hadoop ->> 关于数据分割(Data Split)的思考

    今天开始学习Hadoop这门热门的数据库技术.直接从被奉为Hadoop圣经的<Hadoop The Definitive Guide 4th Edition>入手.第一章作者写到一个关于分 ...

  8. Do the Untwist

      Do the Untwist Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  9. 时间序列算法理论及python实现(2-python实现)

    如果你在寻找时间序列是什么?如何实现时间序列?那么请看这篇博客,将以通俗易懂的语言,全面的阐述时间序列及其python实现. 时间序列算法理论详见我的另一篇博客:时间序列算法理论及python实现 - ...

  10. POJ-3484 Showstopper---二分+前缀和

    题目链接: https://cn.vjudge.net/problem/POJ-3484 题目大意: 给出一系列等差数列,给出第一项和最后一项和公差 这些等差数列中每个数出现的次数只有一个是奇数,找出 ...