(四)openEuler欧拉系统防火墙及yum源配置指南

淘金铲 2024-10-04 16:07:03 阅读 62

目录

一、yum源配置

二、配置防火墙

三、总结


一、yum源配置

最小化安装常用的命令无法使用,需要进行yum源安装

如出现下图安装报错,需对yum源配置

1.1、配置yum源步骤:

上传openEuler镜像文件

<code>1、创建挂载目录:

mkdir -p /mount/iso

2、镜像挂载 :

mount -o loop  ./openEuler-22.03-LTS-x86_64-dvd.iso(镜像上传目录) /mount/iso/ 

3、yum库配置 :

vi /etc/yum.repos.d/openEuler.repo

添加如下参数(注释所有原有信息):

[openEuler] 

name=openEuler 

baseurl=file:///mount/iso

gpgcheck=no

4、设置开机自动挂载

vi /etc/fstab

/root/openEuler-22.03-LTS-x86_64-dvd.iso   /mount/iso    iso9660  ro,loop   0 0

5、安装完成验证镜像源是否成功:

yum -y install net-tools(出现下图为挂载成功)

二、配置防火墙

openEuler默认启用了firewalld服务

状态查看:

service firewalld status

关闭防火墙:

systemctl stop firewalld.service

如果你需要远程连接服务器,您可以根据需要进行配置。例如,开放SSH端口:

firewall-cmd --permanent --add-service=ssh(默认已添加)

firewall-cmd --reload

firewall-cmd --zone=public --list-ports(查看已添加策略)

firewall-cmd --zone=public --list-all

注意(考虑到安全因素,可能需要修改ssh默认端口,修改完会出现无法重启ssh,可按如下步骤解决)

重启报错如下图: 

 可修改配置文件 /etc/selinux/config 中的参数:

<code>

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

# enforcing - SELinux security policy is enforced.

# permissive - SELinux prints warnings instead of enforcing.

# disabled - No SELinux policy is loaded.

SELINUX=disabled

# SELINUXTYPE= can take one of these three values:

# targeted - Targeted processes are protected,

# minimum - Modification of targeted policy. Only selected processes are protected.

# mls - Multi Level Security protection.

SELINUXTYPE=targeted

SELINUX=disabled 的作用是禁用 SELinux

SELINUX=enforcing:

SELinux 处于强制模式,安全策略将被强制执行。系统会阻止所有违反安全策略的操作,sshd服务的端口配置与SELinux策略不兼容,会导致端口无法修改或服务无法启动。故需要修改为SELINUX=disabled,完全禁用 SELinux 功能。系统在启动时不会加载 SELinux 安全模块

修改完成后重启服务器生效:

将修改的ssh服务端口号,添加到防火墙:

容许所有IP访问:

firewall-cmd --permanent --add-port=64922/tcp (添加规则)

firewall-cmd --permanent --remove-port=64922/tcp (删除规则)

firewall-cmd --reload

容许指定IP访问:

firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.159.150" port protocol="tcp" port="64922" accept"(添加规则)code>

firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.159.150" port protocol="tcp" port="64922" accept" (删除规则)code>

firewall-cmd --reload

再次重启ssh服务,可以完成重启,可进行远程连接

三、总结

通过上述步骤,能够成功完成openEuler系统防火墙及yum源配置,如果您在配置过程中遇到任何问题,可私信或留言我,后续为大家持续更新openEuler欧拉系统的常见问题及配置解决方法



声明

本文内容仅代表作者观点,或转载于其他网站,本站不以此文作为商业用途
如有涉及侵权,请联系本站进行删除
转载本站原创文章,请注明来源及作者。