CentOS7使用firewalld和selinux
如何查看和使用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
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的更多相关文章
- CentOS7使用firewalld打开关闭防火墙与端口(转载)
1.firewalld的基本使用 启动: systemctl start firewalld 查看状态: systemctl status firewalld 停止: systemctl disabl ...
- 关于学习CentOS7使用firewalld打开关闭防火墙和端口
1.firewalld简介 firewalld是centos7的一大特点,主要有两个优点:一是支持动态更新,不需要重启服务:二就是加入了防火墙的“zone”概念. firewalld有图形界面和工具界 ...
- CentOS7使用firewalld打开关闭防火墙与端口(转)
CentOS7使用firewalld打开关闭防火墙与端口 1.firewalld的基本使用 启动: systemctl start firewalld 关闭: systemctl stop ...
- Centos7 iptables firewalld防火墙与selinux配置
一.iptables防火墙 1.基本操作 # 查看防火墙状态 service iptables status # 停止防火墙 service iptables stop # 启动防火墙 service ...
- CentOS7 关闭防火墙和selinux
本文将简单介绍在CentOS7上如何临时和永久关闭防火墙和selinux. 关闭防火墙 # 查看防火墙状态 [root@localhost ~]# systemctl status firewalld ...
- 5分钟理解Centos7防火墙firewalld
版权声明:本内容为原创内容,转载请声明出处. 原文地址:http://www.excelib.com/article/287/show firewalld简介 Centos7中默认将原来的防火墙ipt ...
- Linux_CentOS 中systemctl 管理服务、防火墙 firewalld 以及 SELinux 配置
使用 systemctl 管理服务 systemctl 就是 service 和 chkconfig 这两个命令的整合,在 CentOS 7 就开始被使用了,systemctl是系统服务管理器命令,它 ...
- CentOS7的防火墙以及selinux介绍/安装telnet命令/安装netstat与ifconfig命令
简介:firewall防火墙的使用 防火墙:主要用户信息安全防护,主要有软件防火墙和硬件防火墙.firewalld防火墙是软件防火墙,在centos7 之前默认采用的防火墙是iptables,而在ce ...
- CentOS7使用firewalld打开关闭防火墙与端口
1.firewalld的基本使用 启动: systemctl start firewalld 查看状态: systemctl status firewalld 停止: systemctl disab ...
随机推荐
- python小练习:读入一个考试得分,判断这个分数是哪个等级,并输出,考虑异常场景
读入一个考试得分,判断这个分数是哪个等级,并输出. 等级:>=90 优 ,>=80且小于90 良,>=70 且小于80,中,>=60且<70及格 <60 不及格 ...
- Spark With Mongodb 实现方法及error code -5, 6, 13127解决方案
1.spark mongo 读取 val rdd = MongoSpark.builder().sparkSession(spark).pipeline(Seq(`match`(regex(" ...
- crontab 在指定时间范围每隔2小时执行一次和指定时间执行实例
crontab 在指定时间范围每隔2小时执行一次和指定时间执行,下面实例实现了:10-23点每两个小时执行一次,2点执行一次,分钟依次是1 2 3 ,没有24点的,晚上12点是0点注:*代表所有的取值 ...
- ESB(Enterprise Service Bus)企业服务总线介绍
ESB(Enterprise Service Bus)企业服务总线介绍 ESB全称为Enterprise Service Bus,即企业服务总线.它是传统中间件技术与XML.Web服务等技术结合的产物 ...
- python--元组tuple
元组与列表一样,都是序列.但元组不能修改内容(列表允许) 默认的,元组通过圆括号括起来 1. 使用type函数查看类型 numbers = (1,2,3,4,5,6,7,8,9,0) print(ty ...
- [转载]Cookie与Session的区别与联系及生命周期
前几天面试问了一个问题,当时记不太清了,上网查了下发现这个问题还真的很有讲究而且很重要,自己总结下做下记录. 一.Session与Cookie介绍 这些都是基础知识,不过有必要做深入了解.先简单介绍一 ...
- Python学习路线人工智能线性代数知识点汇总
人工智能和数据分析相关的线性代数知识.比如什么是矢量,什么是矩阵,矩阵的加减乘除.矩阵对角化,三角化,秩,QR法,最小二法.等等 矢量: 高中数学中都学过复数,负数表达式是: a+bi 复数实际上和二 ...
- JS 和 Jquery 的一些常用效果
https://www.cnblogs.com/beiz/tag/%E7%BD%91%E9%A1%B5%E5%B8%B8%E8%A7%81%E6%95%88%E6%9E%9C/ 北执
- GoldenGate实时投递数据到大数据平台(2)- Cassandra
简介 GoldenGate是一款可以实时投递数据到大数据平台的软件,针对apache cassandra,经过简单配置,即可实现从关系型数据将增量数据实时投递到Cassandra,以下介绍配置过程. ...
- Servlet上传下载
下面是一个jsp页面(method和enctype必须要有) //页面<form action="file?file=upLoadByjs" method="pos ...