LINUX-防火墙简单操作

一、防火墙规则

防火墙的一些简单操作

# 1、查看防火墙状态
systemctl status firewalld

# 2、关闭防火墙
systemctl stop firewalld

# 3、开启防火墙
systemctl start firewalld

 防火墙的简单规则

# 1、查看防火墙放行的服务
firewall-cmd --list-all

# 2、在防火墙中放行某服务,并设为永久生效
firewall-cmd --permanent --add-service=&协议名

# 3、在防火墙中放行某端口,并设为永久生效
firewall-cmd --permanent --add-port=8088/tcp

# 4、刷新(重新加载)防火墙配置
firewall-cmd --reload

 网络服务及协议名对应关系

服务名 	协议名
vsftpd 	ftp
NFS 	        nfs
SAMBA 	windows:cifs
linux:      smb、nmb
APACHE 	http/https

 二:selinux规则

SElinux也是Linux操作系统的一种安全访问规则。用于确定哪个进程可以访问哪些文件、目录和端口的一组安全规则。保护的对象是服务(进程)、服务对应的文件(目录)、服务对应的端口。


SElinux可以被看作是与标准权限系统并行的权限系统,如果selinux开启,以root身份运行进程,访问文件不光要受用户对文件访问权限的限制,还要受进程对文件selinux上下文类型的限制,否则,就算是root用户运行的进程,也不一定能访问某个文件。

 

说明:

名称 	                  模式 	                 作用
enforcing 	      强制模式 	                拒绝非法访问并录入日志
permissive      许可模式(警告模式) 	暂时允许非法访问并录入日志
disabled 	      禁用模式 	                允许非法访问且不录入日志

 简单操作:

#获取selinux状态
[root@localhost ~]# getenforce

# 临时切换:
[root@localhost ~]# setenforce 0	#临时关闭selinux策略 enforcing  -> permissive
[root@localhost ~]# setenforce 1	#临时开启selinux策略 permissive -> enforcing

# 永久切换:
[root@localhost ~]# vim /etc/selinux/config
SELINUX=enforcing/permissive/disabled
[root@localhost ~]# reboot

 

 

文章摘取:https://www.cnblogs.com/wzgwzg/p/15602936.html 
本随笔用于自己学习记录

 

posted @ 2021-12-02 11:14  黑墨罗少  阅读(392)  评论(0编辑  收藏  举报