今天推荐的是Rocky Linux,与Centos几乎无异,命令通用,安装简单,开源,对标RH而进行的代码重构,且作者是前Centos项目的创始人,提供长期支持,提供Centos迁移方案等,是我认为该系统是下一个Centos。
Vmware下安装Rocky Linux9.4
Vmware下安装Rocky Linux9.4-CSDN博客
一、修改网卡
如果是前边用了 爱快路由器, 我们只需要设置VM网卡为仅主机模式
后边的不用看了。
看我虚拟机:
LAN区段
这个网络模式其实就是一个虚拟的自定义局域网,只要将多台虚拟机都选择同一LAN区段,将网卡都设置成一个网段的IP,就可以实现互相通信,它是不能上外网的。
查看网卡,查看到两张网卡,分别是ens33和ens34
ls /etc/NetworkManager/system-connections/
ens33.nmconnection ens34.nmconnection
根据实际需求配置网卡,这里演示修改第一张网卡ens33的网络配置
vi /etc/NetworkManager/system-connections/ens33.nmconnection
原有内容
[connection]
id=ens33
uuid=3367ca47-aea6-38d7-b69c-99a7e5e85979
type=ethernet
autoconnect-priority=-999
interface-name=ens33
timestamp=1726163668
[ethernet]
[ipv4]
method=auto
[ipv6]
addr-gen-mode=eui64
method=auto
修改的内容
[ipv4]
method=manual
address1=10.0.0.150/24,10.0.0.2
dns=114.114.114.114;8.8.8.8
manual为手动指定ip地址,也就是静态ip
address1为10.0.0 网段,网段注意与虚拟机查到仅主机模式的网段一致,24为子网掩码位数。
dns有多个用分号;隔开
修改后:
[connection]
id=ens33
uuid=3367ca47-aea6-38d7-b69c-99a7e5e85979
type=ethernet
autoconnect-priority=-999
interface-name=ens33
timestamp=1726163668
[ethernet]
#[ipv4]
#method=auto
[ipv4]
method=manual
address1=10.0.0.150/24,10.0.0.2
dns=114.114.114.114;8.8.8.8
[ipv6]
addr-gen-mode=eui64
method=auto
[proxy]
配置 172.16.1.150 网卡
这一步 rockylinux 9.4 需要再桌面操作, 目前还没找到到好的方法
编辑完后,在目录:
/etc/NetworkManager/system-connections
cat 配置\ 1.nmconnection
内容:
[connection]
id=eth2
uuid=9a8d49cf-af43-4981-a671-c95eebfceec1
type=ethernet
timestamp=1740624285
[ethernet]
[ipv4]
address1=172.16.1.150/24
ignore-auto-dns=true
method=manual
[ipv6]
addr-gen-mode=default
method=auto
[proxy]
测试一下:
阿斯蒂芬
二、备份及更换系统软件源
备份及更换系统软件源,命令如下
sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g' \
-i.bak \
/etc/yum.repos.d/[Rr]ocky*.repo
创建新的数据缓存,命令如下
dnf makecache
三、设置防火墙
可选操作,根据实际需求设置
这里演示关闭并禁用firewalld防火墙,使用iptables防火墙。关于iptables和firewalld的区别可自行查找相关资料。
关闭并禁用firewalld防火墙
systemctl stop firewalld
systemctl disable firewalld
使用iptables防火墙(合适的时候使用)一般内网我们用阿里云的白名单
yum -y install iptables-services
systemctl start iptables
iptables -F
systemctl enable iptables
service iptables save
禁用 Selinux
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
grubby --update-kernel ALL --args selinux=0
grubby --info DEFAULT
四、设置时区
检查时区是否是上海
timedatectl
时区如果不是Asia/Shanghai
,使用如下命令设置时区
timedatectl set-timezone Asia/Shanghai
安装命令
可选操作,最小安装版的Linux,很多软件需要自行安装,根据实际需要安装必要的命令
例如:vim、net-tools
yum update -y
yum install -y vim
yum install -y net-tools
欢迎来撩 : 汇总all