SELinux模式的切换
enforcing(强制)
permissive(宽松)
disabled(禁用)
与disabled模式相关的切换都需要重启
getenforce ----查看模式
临时切换:setenforce 1|0 (1-强制,0-宽松)
永久配置:/etc/selinux/config
搭建基本的Web服务
yum -y install httpd
systemctl restart httpd
systemctl enable httpd(开机自启)
本机访问测试>>> firefox ip
firefox 172.25.0.11
书写网页文件:
/var/www/html (httpd默认网页文件路径)
index.html (httpd默认为网页名称)
搭建基本的ftp服务
FTP------文件传输协议
yum -y install vsftpd
systemctl restart vsftpd
systemctl enable vsftpd
本机访问测试: firefox ftp://ip
firefox ftp://172.25.0.11
FTP默认共享路径:
var/ftp
防火墙策略:
作用:过滤和隔离
允许出站,过滤入站
firewalld服务基础
firewall-cmd firewall-config(图形)
--public 仅允许访问本机的sshd dhcp ping等少数几个服务
--trusted 允许任何访问
--block 阻塞任何来访请求(明确拒绝)
--drop 丢弃任何来访的数据包(没有回应,直接丢弃,节省资源)
默认区域(public): root用户可以修改
[[email protected] ~]# firewall-cmd --get-default-zone #查看默认区域
public
[[email protected] ~]# firewall-cmd --set-default-zone=block #修改默认区域
success
[[email protected] ~]# firewall-cmd --get-default-zone
block
数据包内容:源IP地址 目标IP地址 数据
public区域添加服务的协议
[[email protected] ~]# firewall-cmd --zone=public --list-all public (default, active) interfaces: eth0 sources: services: dhcpv6-client ssh ports: masquerade: no forward-ports: icmp-blocks: rich rules:
[[email protected] ~]# firewall-cmd --zone=public --add-service=ftp success [[email protected] ~]# firewall-cmd --zone=public --add-service=http success [[email protected] ~]# firewall-cmd --zone=public --list-all public (default, active) interfaces: eth0 sources: services: dhcpv6-client ftp http ssh ports: masquerade: no forward-ports: icmp-blocks: rich rules:
[[email protected] ~]# firefox 172.25.0.11 [[email protected] ~]# firefox ftp://172.25.0.11
防火墙实现永久策略:
--permanent(永久)
firewall-cmd --reload
[[email protected] ~]# firewall-cmd --permanent --zone=public --add-service=http success [[email protected] ~]# firewall-cmd --permanent --zone=public --add-service=ftp success [[email protected] ~]# firewall-cmd --reload success [[email protected] ~]# firewall-cmd --zone=public --list-all public (default, active) interfaces: eth0 sources: services: dhcpv6-client ftp http ssh ports: masquerade: no forward-ports: icmp-blocks: rich rules:
原文地址:https://www.cnblogs.com/ray-mmss/p/9938673.html