转载自莫小安的博客:https://www.cnblogs.com/moxiaoan/p/5683743.html
如何查看和使用selinux https://blog.csdn.net/edide/article/details/52389946

一键关闭SELinux和firewalld

 #!/bin/bash
# echo "此段代码是判断和永久关闭SELinux"
sleep 2 sefile=/etc/selinux/config if [ "`getenforce`" == "Enforcing" ]; then
echo "selinux is starting,the scripts will set up"
setenforce 0
else
if [ "`getenforce`" == "Permissive" ]; then
echo "selinux was down"
fi
fi if [ `grep 'SELINUX=enforcing' $sefile | wc -l` -eq 1 ]; then
echo "selinux is start up with system boot,the scripts will set up."
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' $sefile
else
if [ `grep 'SELINUX=disabled' $sefile | wc -l` -eq 1 ]; then
echo "selinux will not start up with your system boot."
fi
fi sleep 2
echo
echo "此段代码是判断和永久关闭firewalld"
sleep 2 systemctl status firewalld &>/tmp/1.txt
fifile=/tmp/1.txt if [ `head -n 3 $fifile | grep 'running' | wc -l` -eq 1 ]; then
echo "firewalld is running,the script will set up."
systemctl stop firewalld
systemctl disable firewalld &>/dev/null
else
echo "firewalld is stopped"
fi

一键关闭SELinux和firewalld

1、firewalld的基本使用
启动: systemctl start firewalld
关闭: systemctl stop firewalld
查看状态: systemctl status firewalld 
开机禁用  : systemctl disable firewalld
开机启用  : systemctl enable firewalld
 

2.systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。

启动一个服务: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
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed


3.配置firewalld-cmd

查看版本: firewall-cmd --version
查看帮助: firewall-cmd --help
显示状态: firewall-cmd --state
查看所有打开的端口: firewall-cmd --zone=public --list-ports
更新防火墙规则: firewall-cmd --reload
查看区域信息: firewall-cmd --get-active-zones
查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0
拒绝所有包:firewall-cmd --panic-on
取消拒绝状态: firewall-cmd --panic-off
查看是否拒绝: firewall-cmd --query-panic


那怎么开启一个端口呢?

添加
firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent永久生效,没有此参数重启后失效)

重新载入
firewall-cmd --reload

查看
firewall-cmd --zone= public --query-port=80/tcp

删除
firewall-cmd --zone= public --remove-port=80/tcp --permanent

 

CentOS7使用firewalld和selinux的更多相关文章

  1. CentOS7使用firewalld打开关闭防火墙与端口(转载)

    1.firewalld的基本使用 启动: systemctl start firewalld 查看状态: systemctl status firewalld 停止: systemctl disabl ...

  2. 关于学习CentOS7使用firewalld打开关闭防火墙和端口

    1.firewalld简介 firewalld是centos7的一大特点,主要有两个优点:一是支持动态更新,不需要重启服务:二就是加入了防火墙的“zone”概念. firewalld有图形界面和工具界 ...

  3. CentOS7使用firewalld打开关闭防火墙与端口(转)

    CentOS7使用firewalld打开关闭防火墙与端口       1.firewalld的基本使用 启动: systemctl start firewalld 关闭: systemctl stop ...

  4. Centos7 iptables firewalld防火墙与selinux配置

    一.iptables防火墙 1.基本操作 # 查看防火墙状态 service iptables status # 停止防火墙 service iptables stop # 启动防火墙 service ...

  5. CentOS7 关闭防火墙和selinux

    本文将简单介绍在CentOS7上如何临时和永久关闭防火墙和selinux. 关闭防火墙 # 查看防火墙状态 [root@localhost ~]# systemctl status firewalld ...

  6. 5分钟理解Centos7防火墙firewalld

    版权声明:本内容为原创内容,转载请声明出处. 原文地址:http://www.excelib.com/article/287/show firewalld简介 Centos7中默认将原来的防火墙ipt ...

  7. Linux_CentOS 中systemctl 管理服务、防火墙 firewalld 以及 SELinux 配置

    使用 systemctl 管理服务 systemctl 就是 service 和 chkconfig 这两个命令的整合,在 CentOS 7 就开始被使用了,systemctl是系统服务管理器命令,它 ...

  8. CentOS7的防火墙以及selinux介绍/安装telnet命令/安装netstat与ifconfig命令

    简介:firewall防火墙的使用 防火墙:主要用户信息安全防护,主要有软件防火墙和硬件防火墙.firewalld防火墙是软件防火墙,在centos7 之前默认采用的防火墙是iptables,而在ce ...

  9. CentOS7使用firewalld打开关闭防火墙与端口

    1.firewalld的基本使用 启动: systemctl start firewalld 查看状态: systemctl status firewalld  停止: systemctl disab ...

随机推荐

  1. ATM-JAVA程序 //程序有5处相同错误,找不出原因 转账功能没有实现,修改密码来不及实现了

    package JCC;//信1705-3 20173681 靳晨晨import java.io.BufferedReader;import java.io.File;import java.io.F ...

  2. MongoDB With Spark遇到的2个错误,不能初始化和sample重复的key

    1.$sample stage could not find a non-duplicate document while using a random cursor 这个问题比较难解决,因为我用mo ...

  3. 产品经理-需求分析-用户故事-敏捷开发 详解 一张图帮你了解Scrum敏捷流程

    产品经理-需求分析-用户故事-敏捷开发 详解 用户故事是从用户的角度来描述用户渴望得到的功能.一个好的用户故事包括三个要素:1. 角色:谁要使用这个功能.2. 活动:需要完成什么样的功能.3. 商业价 ...

  4. asp.net热门框架

    http://developer.51cto.com/art/201501/464292.htm

  5. shell命令行快捷键

    ctrl+a[A]:将光标移到命令行开头 ctrl+e[E]:将光标移到命令行结尾 ctrl+c[C]:强制终止命令执行 ctrl+u[U]:删除/剪切光标之前的所有字符 ctrl+y[Y]:粘贴ct ...

  6. Django后端项目---- rest framework(3)

    一.版本 程序也来越大时,可能通过版本不同做不同的处理 没用rest_framework之前,我们可以通过以下这样的方式去获取. class UserView(APIView): def get(se ...

  7. 前端框架VUE----es6简单介绍

    1.ECMAScript 6 简介 ECMAScript 6.0(以下简称 ES6)是 JavaScript 语言的下一代标准,已经在 2015 年 6 月正式发布了.它的目标,是使得 JavaScr ...

  8. echo 换行与否

    echo默认是有换行的, -n的时候, 是不换行的.

  9. opencv3.1线性可分svm例子及函数分析

    https://www.cnblogs.com/qinguoyi/p/7272218.html //摘自:http://docs.opencv.org/2.4/doc/tutorials/ml/int ...

  10. PXC备份方式总结

    记录一下. 1.mysqldump数据导出 关于GTID: GTID是MySQL5.6以后,加入了全局事务 ID (GTID) 来强化数据库的主备一致性,故障恢复,以及容错能力. A global t ...