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 pprint
使用 pprint 模块 pprint 模块( pretty printer ) 用于打印 Python 数据结构. 当你在命令行下打印特定数据结构时你会发现它很有用(输出格式比较整齐, 便于阅读). ...
- grouping sets 的使用
grouping sets 可以用于在计算分组聚合函数值的同时计算合计值 -- 查询结果group_id为NULL的那一行即为合计值 select group_id , count(distinct ...
- NGINX的几个应用场景
NGINX的几个应用场景 两个参考地址: NGINX的百度百科:https://baike.baidu.com/item/nginx/3817705?fr=aladdin NGINX的中文网站:htt ...
- The Little Prince-12/17
The Little Prince-12/17 今年四六级吐槽,说到做到!!!文思泉涌了兄弟们! “这就是你自己的错了,我本来并不想给你带来任何痛苦的,可你却要我驯服你……可你要哭了,可你什么好处也没 ...
- Service_name 和Sid的区别
Service_name:该参数是由oracle8i引进的.在8i以前,使用SID来表示标识数据库的一个实例,但是在Oracle的并行环境中,一个数据库对应多个实例,这样就需要多个网络服务名,设置繁琐 ...
- 处理springmvc的post和get提交参数乱码问题
1,post 配置CharacterEncodingFilter拦截器 2,get 在tomcat的Connect 上配置uri 编码
- OpenStack平台上,windows云主机可以ping通百度但是无法打开网页,部分其它网页可以打开
问题描述: 在OpenStack平台上的64位Windows7虚拟机,可以ping通百度,但是却无法打开百度网页. 于是,笔者又对其它网址进行的测试,发现淘宝.京东.携程部分网页可以打开,而新浪等等网 ...
- QT开发基础教程
http://www.qter.org/portal.php?mod=view&aid=11
- Tensorflow学习笔记02-Session,Variable,placeholder
Session会话控制 使用tensorflow创建两个矩阵,并使其相乘 matrix1=tf.constant([[3,3]]) matrix2=tf.constant([[2], [2]]) pr ...
- Windbg解决系统蓝屏
win10企业版连续两天遭遇系统蓝屏, 今天就各种检查,准备好好地研究一下这个问题,以下是整个过程: 首先,找到系统蓝屏时的错误日志: [计算机] --> [管理] --> [系统工具] ...