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. 【Android】4.0 神一样的仪式感:Android第一个项目HelloWorld——eclipse

    进入Eclipse,在左侧栏右击: 新建 “Android Application Project”项目,如果new之后没有,选择“Project”中“Android”目录下的 “Android Ap ...

  2. 【Android】2.0 Android开发环境的搭建——Eclipse

    1.0 eclipse,这可不算谷歌开发的,是IBM公司开发的,而且是Java语言写的 2.0 eclipse怎么下.百度“eclipse”,进入eclipse官网 然后,瞎几把下吧……,实在不行百度 ...

  3. mac的svn

    http://xclient.info/s/cornerstone.html?t=c5242a66e53f1d866afe8c42aace2738c04ce9ee#versions 破解版的地址 打开 ...

  4. Id_Name

    <bean name="u" class="com.bjsxt.dao.impl.UserDAOImpl"></bean> <be ...

  5. 杂谈spring、springMVC

    一.背景 目前项目组都在用SSM(spring+springMVC+mybatis)开发项目 大家基本都停留在框架的基本使用阶段,对框架的职责并不清晰,导致配置文件出现了不少问题 在这简单讲解一下sp ...

  6. Azure进阶攻略丨共享访问签名是个什么东东?

    Azure 进阶攻略]一经推出便受到了广大粉丝的热情追捧,大家纷纷表示涨了姿势,并希望能了解更多的攻略~根据大家的投票结果,本期,小编将为大家讲解“如何生成 Shared Access Signatu ...

  7. 3元购买微信小程序解决方案一个月

    一.登录微信公众平台https://mp.weixin.qq.com/ 二.点击立即注册.注意:这里不要用微信公众号登录,小程序账号和微信公众号是不同的. 三.在注册页面点击小程序板块. 四.进入小程 ...

  8. Smokeping配置调整

    smokeping两种邮件报警方式 一 .自带sendmail报警 修改这两句话to = 收件邮箱,多个逗号分隔from = smokealert@本机IP /usr/local/smokeping/ ...

  9. YouTube 1080P高清视频下载方法

    在国内在线视频网站还停留在1080P蓝光的时候,YouTube早已经支持4K和8K分辨率的极清视频.虽然4K和8K的清晰度比1080P高了许多档次,但是大部分人的电脑播放4K视频还是很卡的,所以目前来 ...

  10. typescript 添加基础类型的扩展方法

    以时间转换为案例: //声明接口,也是在声明date这个基础类型要定义一个format的扩展方法,不写接口声明会报错 interface Date { Format(fmt:string):strin ...