Linux 内核级加强型火墙

一、内核级加强型火墙

查看:getenforce
开启后给每个文件和程序添加标签——安全上下文
匹配则可以访问

文件是功能标签
程序是加了波尔开关

修改状态文件

状态:
enforcing  强制:拒绝访问,有警告信息
permissive 警告:可以访问,有警告信息
disabled   关闭:

切换:setenforce 0 切换到警告状态  (开启模式下)
     setenforce 1 切换到强制状态

1、对文件的影响

临时更改上下文
[root@localhost ~]# ls -Zb /ftphome/
drwxr-xr-x. root root unconfined_u:object_r:default_t:s0 westos1

[root@localhost ~]#  chcon -t public_content_t /ftphome/ -R
[root@localhost ~]# ls -Zb /ftphome/
drwxr-xr-x. root root unconfined_u:object_r:public_content_t:s0 westos1

改为关闭状态重起
在改为强制状态重起
重起后临时更改失效



对文件的影响
永久更改上下文
查看:
[root@localhost ~]# ls -Zb /var/ftp/


更改:
[root@localhost ~]# semanage fcontext -l | grep /var/ftp/


[root@localhost ~]# semanage fcontext -l | grep /ftthome/
[root@localhost ~]# semanage fcontext -a -t public_content_t '/ftthome(/.*)'
[root@localhost ~]# semanage fcontext -l | grep /ftthome/


restorecon -RvvF /ftthome/

测试
[root@localhost ~]# ls -Zb /ftthome/

对程序的影响

确保警告模式下匿名用户能上传
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf
[root@localhost ~]# chgrp ftp /var/ftp/pub/
[root@localhost ~]# chmod 775 /var/ftp/pub/

[root@foundation38 ~]# lftp 172.25.254.138
lftp 172.25.254.138:~> ls

-P  永久开启
[root@localhost ~]# setsebool -P ftpd_anon_write on
[root@localhost ~]# getsebool -a | grep ftp
ftp_home_dir --> off
ftpd_anon_write --> on


日志管理
查看安装包
[root@localhost pub]# rpm -qa | grep setroubleshoot
setroubleshoot-3.2.17-2.el7.x86_64
setroubleshoot-plugins-3.0.59-1.el7.noarch
setroubleshoot-server-3.2.17-2.el7.x86_64
安装
[root@localhost pub]# yum install trouble -y
[root@localhost pub]# yum install setroubleshoot.x86_64 -y

安装后
[root@localhost pub]# cat /var/log/messages
Nov  3 22:20:01 localhost systemd: Starting Session 42 of user root.
Nov  3 22:20:01 localhost systemd: Started Session 42 of user root.

日志存放在
[root@localhost pub]# cat /var/log/audit/audit.log   提供报错
 
[root@localhost pub]# cat /var/log/messages          提供报错原因

猜你喜欢

转载自blog.csdn.net/wanghu66/article/details/83826255