一.CentOS Stream 9/CentOS Stream 10概述CentOS Stream 是 Red Hat Enterprise Linux (RHEL) 的上游开发分支采用“滚动更新”模式。这意味着它介于 Fedora 和 RHEL 之间让你能提前看到 RHEL 未来的功能。特性CentOS Stream 9CentOS Stream 10对应 RHEL 版本RHEL 9 系列RHEL 10 系列内核版本Kernel 5.14Kernel 6.12 (显著更新)Python 默认版本Python 3.9Python 3.12 (性能更强)编译器工具链GCC 11GCC 14 (支持新语言特性)系统架构传统 YUM/DNF引入 System Wide Image (SWI) 和 Bootable Container 概念生命周期维护至 2027 年 (全支持) / 2032 年 (维护支持)预计维护至 2030 年代初代号无特定代号Coughlan二.系统环境服务器版本内核版本CentOS Stream release 10 (Coughlan)6.12.0-212.el10.x86_64CentOS Stream release 95.14.0-687.el9.x86_64三.CentOS Stream 9/CentOS Stream 10配置静态IP3.1 NetworkManager配置静态IPCentOS Stream 9/CentOS Stream 10的网络配置文件不再使用/etc/sysconfig/network-scripts/ifcfg-eth0network服务已经弃用默认使用NetworkManager管理网络配置文件位于/etc/NetworkManager/system-connections/目录下。[rootlocalhost ~]# cd /etc/NetworkManager/system-connections/ [rootlocalhost system-connections]# ls ens160.nmconnection修改配置文件指定机器静态IP为192.168.0.132。address1指定静态IP地址和子网掩码CIDR格式dns指定DNS服务器列表多个地址用分号分隔建议使用国内的DNS服务器地址这样更快比如223.5.5.5;223.6.6.6methodmethodmanual表示强制使用手动配置模式methodauto表示启用 DHCP (动态主机配置协议)动态获取IPgateway指定服务器网关。[rootlocalhost system-connections]# vim ens160.nmconnection [rootlocalhost system-connections]# cat ens160.nmconnection [connection] #网卡名称 idens160 #系统内部用来唯一标识这个连接配置。即使你把 id 改名了UUID 也不会变确保系统不会搞混。 uuid89fcf374-9ca1-30b1-b1dd-ed124953574c #表明这是一个标准的以太网有线网卡连接。 typeethernet #自动连接优先级。这是一个非常低的优先级范围通常是 -999 到 999。 autoconnect-priority-999 #绑定的物理网卡名称。 interface-nameens160 timestamp1775042953 [ethernet] #双工模式设置为半双工。半双工意味着同一时间只能发数据或收数据不能同时进行且容易发生冲突。这会严重限制网卡性能。除非连接的是非 #常古老的集线器Hub或特殊工业设备否则建议改为 duplexfull 或直接删除此行让网卡自动协商。 duplexhalf #强制网卡速率锁定为 10000 Mbps (10 Gbps)。 speed10000 [ipv4] address1192.168.0.132/24 dns223.5.5.5;223.6.6.6;119.29.29.29;182.254.116.116; gateway192.168.0.2 methodmanual [ipv6] #地址生成模式。使用 EUI-64 算法基于网卡的 MAC 地址生成 IPv6 地址的后 64 位。这种方式生成的地址是固定的便于追踪但隐私性不如#默认的“稳定隐私地址”。 addr-gen-modeeui64 #自动模式。 methodauto [proxy]重载配置文件并重启。[rootlocalhost system-connections]# systemctl restart NetworkManager [rootlocalhost system-connections]# systemctl status NetworkManager ● NetworkManager.service - Network Manager Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; preset: enabled) Active: active (running) since Thu 2026-04-02 22:06:20 CST; 8s ago Invocation: ed6964f8bf7d4a7aa7301b361329c36a Docs: man:NetworkManager(8) Main PID: 1841 (NetworkManager) Tasks: 5 (limit: 23984) Memory: 3.4M (peak: 4.3M) CPU: 52ms CGroup: /system.slice/NetworkManager.service └─1841 /usr/sbin/NetworkManager --no-daemon 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.7000] device (ens1 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.7015] policy: set 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.7054] device (ens1 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.7071] device (ens1 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.7072] device (ens1 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.7075] manager: Net 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.7076] device (ens1 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.7079] manager: Net 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.7080] manager: sta 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.8850] policy: set-在/etc/NetworkManager/system-connections/ens160.nmconnection里配置了DNS之后/etc/resolv.conf 里的DNS也会变化。[rootlocalhost system-connections]# cat /etc/resolv.conf # Generated by NetworkManager nameserver 223.5.5.5 nameserver 223.6.6.6 nameserver 119.29.29.29 # NOTE: the libc resolver may not support more than 3 nameservers. # The nameservers listed below may not be recognized. nameserver 182.254.116.116查看IP发现ip配置成功也能上网了。[rootlocalhost system-connections]# ip a 1: lo: LOOPBACK,UP,LOWER_UP mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host noprefixroute valid_lft forever preferred_lft forever 2: ens160: BROADCAST,MULTICAST,UP,LOWER_UP mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:de:bf:87 brd ff:ff:ff:ff:ff:ff altname enp3s0 altname enx000c29debf87 inet 192.168.0.132/24 brd 192.168.0.255 scope global noprefixroute ens160 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fede:bf87/64 scope link noprefixroute valid_lft forever preferred_lft forever #查看路由 [rootlocalhost system-connections]# ip r default via 192.168.0.2 dev ens160 proto static metric 100 192.168.0.0/24 dev ens160 proto kernel scope link src 192.168.0.132 metric 100 #可以上网 [rootlocalhost system-connections]# ping qq.com PING qq.com (113.108.81.189) 56(84) 字节的数据。 64 字节来自 113.108.81.189: icmp_seq1 ttl128 时间61.3 毫秒 64 字节来自 113.108.81.189: icmp_seq2 ttl128 时间71.2 毫秒 64 字节来自 113.108.81.189: icmp_seq3 ttl128 时间69.3 毫秒 64 字节来自 113.108.81.189: icmp_seq4 ttl128 时间71.7 毫秒 64 字节来自 113.108.81.189: icmp_seq5 ttl128 时间69.7 毫秒 64 字节来自 113.108.81.189: icmp_seq6 ttl128 时间68.2 毫秒 ^C --- qq.com ping 统计 --- 已发送 7 个包 已接收 6 个包, 14.2857% packet loss, time 6004ms rtt min/avg/max/mdev 61.309/68.572/71.737/3.449 ms3.2 nmcli配置静态IP在 CentOS Stream 9 中网络管理已经完全转向由NetworkManager主导。nmcliNetworkManager Command Line Interface是其核心的命令行工具。相比传统的ifcfg脚本或ip addr命令nmcli的优势在于它的配置是持久化的重启不失效且能实时反映 NetworkManager 的状态。nmcli常用命令操作类型命令示例说明查看状态nmcli general status查看 NetworkManager 整体运行状态查看设备nmcli device status查看所有网卡及其连接状态查看连接nmcli connection show列出所有已保存的连接配置文件启用连接nmcli connection up ID激活指定的连接配置禁用连接nmcli connection down ID断开指定的连接重新加载nmcli connection reload修改配置文件后重新加载到内存修改网卡为静态IPIP地址配置为192.168.0.132。ipv4.addresses静态IP地址CIDR格式ipv4.gateway默认网关ipv4.dnsDNS服务器列表逗号分隔。[rootlocalhost ~]# nmcli connection modify ens33 \ ipv4.addresses 192.168.0.132/24 \ ipv4.gateway 192.168.0.2 \ ipv4.dns 223.5.5.5,8.8.8.8 \ ipv4.method manual激活配置。[rootlocalhost ~]# nmcli connection down ens33 sudo nmcli connection up ens33查看具体连接详情。[rootlocalhost ~]# nmcli connection show ens33四.centos9/centos10配置dnf/yum源4.1 dnf概述dnf (Dandified YUM)是基于 RPM 的 Linux 发行版的新一代软件包管理器专为 Fedora、RHEL 8 及 CentOS Stream 9/10 等系统设计作为yum 的直接替代品dnf 解决了 yum 的性能瓶颈和功能限制同时保持了类似的命令语法在 CentOS Stream 9/10 中yum 命令实际上是指向 dnf 的符号链接执行 yum 时实际调用的是 dnf 功能。[rootlocalhost ~]# ll -h /usr/bin/yum lrwxrwxrwx. 1 root root 5 2月16日 08:00 /usr/bin/yum - dnf-3 [rootlocalhost ~]# ll -h /usr/bin/dnf lrwxrwxrwx. 1 root root 5 2月16日 08:00 /usr/bin/dnf - dnf-34.2 dnf常用命令命令类型命令示例功能描述使用场景基础安装sudo dnf install package安装指定软件包安装新软件sudo dnf install package1 package2同时安装多个软件包批量安装sudo dnf install -y package自动确认安装无需交互自动化脚本软件包管理sudo dnf remove package卸载软件包移除不需要的软件sudo dnf update更新所有已安装的软件包系统升级sudo dnf update package更新特定软件包选择性更新sudo dnf autoremove自动清理不再需要的依赖系统精简查询与搜索dnf search keyword搜索软件包查找可用软件dnf info package查看软件包详细信息了解软件详情dnf provides /path/to/file查找提供特定文件的软件包问题排查dnf list installed列出所有已安装软件包系统审计仓库管理dnf repolist列出所有启用的仓库检查源配置dnf repolist --verbose显示仓库详细信息URL、状态等源问题排查sudo dnf config-manager --enable repo启用指定仓库添加新源sudo dnf config-manager --disable repo禁用指定仓库临时移除源缓存管理sudo dnf clean all清除所有缓存元数据和软件包解决缓存问题sudo dnf makecache重建缓存源更新后sudo dnf clean packages仅删除已下载的.rpm文件释放磁盘空间事务与历史dnf history查看所有操作记录审计系统变更dnf history info 5查看第5条记录的详细变更问题分析sudo dnf history undo 5撤销第5条操作系统回滚模块化功能dnf module list列出可用的模块查看多版本软件sudo dnf module enable php:8.0启用特定模块使用指定版本sudo dnf module install php安装模块化软件安装多版本软件高级功能dnf download package --resolve下载软件包及其依赖不安装离线安装准备sudo dnf install ./*.rpm安装本地下载的RPM包离线安装sudo dnf repair尝试自动修复系统解决软件包损坏问题4.3 配置dnf/yum源备份原先的repo文件。[rootlocalhost ~]# cd /etc/yum.repos.d/ [rootlocalhost yum.repos.d]# ls centos-addons.repo centos.repo [rootlocalhost yum.repos.d]# mkdir bak [rootlocalhost yum.repos.d]# mv *.repo bak/ [rootlocalhost yum.repos.d]# ls bak配置阿里云的yum源:ali-centos.repo 。[rootlocalhost yum.repos.d]# cat ali-centos.repo [baseos] nameCentOS Stream $releasever - BaseOS baseurlhttps://mirrors.aliyun.com/centos-stream/$stream/BaseOS/$basearch/os/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h countme1 enabled1 [baseos-debug] nameCentOS Stream $releasever - BaseOS - Debug baseurlhttps://mirrors.aliyun.com/centos-stream/$stream/BaseOS/$basearch/debug/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [baseos-source] nameCentOS Stream $releasever - BaseOS - Source baseurlhttps://mirrors.aliyun.com/centos-stream/$stream/BaseOS/source/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [appstream] nameCentOS Stream $releasever - AppStream baseurlhttps://mirrors.aliyun.com/centos-stream/$stream/AppStream/$basearch/os/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h countme1 enabled1 [appstream-debug] nameCentOS Stream $releasever - AppStream - Debug baseurlhttps://mirrors.aliyun.com/centos-stream/$stream/AppStream/$basearch/debug/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [appstream-source] nameCentOS Stream $releasever - AppStream - Source baseurlhttps://mirrors.aliyun.com/centos-stream/$stream/AppStream/$basearch/debug/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [crb] nameCentOS Stream $releasever - CRB baseurlhttps://mirrors.aliyun.com/centos-stream/$stream/CRB/$basearch/os/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h countme1 enabled1 [crb-debug] nameCentOS Stream $releasever - CRB - Debug baseurlhttps://mirrors.aliyun.com/centos-stream/$stream/CRB/$basearch/debug/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [crb-source] nameCentOS Stream $releasever - CRB - Source baseurlhttps://mirrors.aliyun.com/centos-stream/$stream/CRB/source/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0配置阿里云的yum源:ali-addons.repo 。[rootlocalhost yum.repos.d]# cat ali-addons.repo [highavailability] nameCentOS Stream $releasever - HighAvailability baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/HighAvailability/$basearch/os/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h countme1 enabled0 [highavailability-debug] nameCentOS Stream $releasever - HighAvailability - Debug baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/HighAvailability/$basearch/debug/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [highavailability-source] nameCentOS Stream $releasever - HighAvailability - Source baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/HighAvailability/source/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [nfv] nameCentOS Stream $releasever - NFV baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/NFV/$basearch/os/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h countme1 enabled0 [nfv-debug] nameCentOS Stream $releasever - NFV - Debug baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/NFV/$basearch/debug/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [nfv-source] nameCentOS Stream $releasever - NFV - Source baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/NFV/source/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [rt] nameCentOS Stream $releasever - RT baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/RT/$basearch/os/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h countme1 enabled0 [rt-debug] nameCentOS Stream $releasever - RT - Debug baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/RT/$basearch/debug/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [rt-source] nameCentOS Stream $releasever - RT - Source baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/RT/source/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [resilientstorage] nameCentOS Stream $releasever - ResilientStorage baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/ResilientStorage/$basearch/os/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h countme1 enabled0 [resilientstorage-debug] nameCentOS Stream $releasever - ResilientStorage - Debug baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/ResilientStorage/$basearch/debug/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [resilientstorage-source] nameCentOS Stream $releasever - ResilientStorage - Source baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/ResilientStorage/source/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [extras-common] nameCentOS Stream $releasever - Extras packages baseurlhttp://mirrors.aliyun.com/centos-stream/SIGs/$stream/extras/$basearch/extras-common/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512 gpgcheck1 repo_gpgcheck0 metadata_expire6h countme1 enabled1 [extras-common-source] nameCentOS Stream $releasever - Extras packages - Source baseurlhttp://mirrors.aliyun.com/centos-stream/SIGs/$stream/extras/source/extras-common/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512 gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0安装EPEL 仓库提供额外软件包。[rootlocalhost yum.repos.d]# dnf install epel-release [rootlocalhost yum.repos.d]# pwd /etc/yum.repos.d [rootlocalhost yum.repos.d]# ls ali-addons.repo ali-centos.repo bak epel.repo epel-testing.repo清除所有缓存元数据和软件包。[rootlocalhost ~]# dnf clean all重建缓存以及更新所有已安装的软件包[rootlocalhost ~]# dnf makecache [rootlocalhost ~]# dnf update
CentOS Stream 9/CentOS Stream 10配置静态IP和配置dnf/yum源
一.CentOS Stream 9/CentOS Stream 10概述CentOS Stream 是 Red Hat Enterprise Linux (RHEL) 的上游开发分支采用“滚动更新”模式。这意味着它介于 Fedora 和 RHEL 之间让你能提前看到 RHEL 未来的功能。特性CentOS Stream 9CentOS Stream 10对应 RHEL 版本RHEL 9 系列RHEL 10 系列内核版本Kernel 5.14Kernel 6.12 (显著更新)Python 默认版本Python 3.9Python 3.12 (性能更强)编译器工具链GCC 11GCC 14 (支持新语言特性)系统架构传统 YUM/DNF引入 System Wide Image (SWI) 和 Bootable Container 概念生命周期维护至 2027 年 (全支持) / 2032 年 (维护支持)预计维护至 2030 年代初代号无特定代号Coughlan二.系统环境服务器版本内核版本CentOS Stream release 10 (Coughlan)6.12.0-212.el10.x86_64CentOS Stream release 95.14.0-687.el9.x86_64三.CentOS Stream 9/CentOS Stream 10配置静态IP3.1 NetworkManager配置静态IPCentOS Stream 9/CentOS Stream 10的网络配置文件不再使用/etc/sysconfig/network-scripts/ifcfg-eth0network服务已经弃用默认使用NetworkManager管理网络配置文件位于/etc/NetworkManager/system-connections/目录下。[rootlocalhost ~]# cd /etc/NetworkManager/system-connections/ [rootlocalhost system-connections]# ls ens160.nmconnection修改配置文件指定机器静态IP为192.168.0.132。address1指定静态IP地址和子网掩码CIDR格式dns指定DNS服务器列表多个地址用分号分隔建议使用国内的DNS服务器地址这样更快比如223.5.5.5;223.6.6.6methodmethodmanual表示强制使用手动配置模式methodauto表示启用 DHCP (动态主机配置协议)动态获取IPgateway指定服务器网关。[rootlocalhost system-connections]# vim ens160.nmconnection [rootlocalhost system-connections]# cat ens160.nmconnection [connection] #网卡名称 idens160 #系统内部用来唯一标识这个连接配置。即使你把 id 改名了UUID 也不会变确保系统不会搞混。 uuid89fcf374-9ca1-30b1-b1dd-ed124953574c #表明这是一个标准的以太网有线网卡连接。 typeethernet #自动连接优先级。这是一个非常低的优先级范围通常是 -999 到 999。 autoconnect-priority-999 #绑定的物理网卡名称。 interface-nameens160 timestamp1775042953 [ethernet] #双工模式设置为半双工。半双工意味着同一时间只能发数据或收数据不能同时进行且容易发生冲突。这会严重限制网卡性能。除非连接的是非 #常古老的集线器Hub或特殊工业设备否则建议改为 duplexfull 或直接删除此行让网卡自动协商。 duplexhalf #强制网卡速率锁定为 10000 Mbps (10 Gbps)。 speed10000 [ipv4] address1192.168.0.132/24 dns223.5.5.5;223.6.6.6;119.29.29.29;182.254.116.116; gateway192.168.0.2 methodmanual [ipv6] #地址生成模式。使用 EUI-64 算法基于网卡的 MAC 地址生成 IPv6 地址的后 64 位。这种方式生成的地址是固定的便于追踪但隐私性不如#默认的“稳定隐私地址”。 addr-gen-modeeui64 #自动模式。 methodauto [proxy]重载配置文件并重启。[rootlocalhost system-connections]# systemctl restart NetworkManager [rootlocalhost system-connections]# systemctl status NetworkManager ● NetworkManager.service - Network Manager Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; preset: enabled) Active: active (running) since Thu 2026-04-02 22:06:20 CST; 8s ago Invocation: ed6964f8bf7d4a7aa7301b361329c36a Docs: man:NetworkManager(8) Main PID: 1841 (NetworkManager) Tasks: 5 (limit: 23984) Memory: 3.4M (peak: 4.3M) CPU: 52ms CGroup: /system.slice/NetworkManager.service └─1841 /usr/sbin/NetworkManager --no-daemon 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.7000] device (ens1 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.7015] policy: set 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.7054] device (ens1 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.7071] device (ens1 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.7072] device (ens1 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.7075] manager: Net 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.7076] device (ens1 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.7079] manager: Net 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.7080] manager: sta 4月 02 22:06:20 localhost.localdomain NetworkManager[1841]: info [1775138780.8850] policy: set-在/etc/NetworkManager/system-connections/ens160.nmconnection里配置了DNS之后/etc/resolv.conf 里的DNS也会变化。[rootlocalhost system-connections]# cat /etc/resolv.conf # Generated by NetworkManager nameserver 223.5.5.5 nameserver 223.6.6.6 nameserver 119.29.29.29 # NOTE: the libc resolver may not support more than 3 nameservers. # The nameservers listed below may not be recognized. nameserver 182.254.116.116查看IP发现ip配置成功也能上网了。[rootlocalhost system-connections]# ip a 1: lo: LOOPBACK,UP,LOWER_UP mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host noprefixroute valid_lft forever preferred_lft forever 2: ens160: BROADCAST,MULTICAST,UP,LOWER_UP mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:de:bf:87 brd ff:ff:ff:ff:ff:ff altname enp3s0 altname enx000c29debf87 inet 192.168.0.132/24 brd 192.168.0.255 scope global noprefixroute ens160 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fede:bf87/64 scope link noprefixroute valid_lft forever preferred_lft forever #查看路由 [rootlocalhost system-connections]# ip r default via 192.168.0.2 dev ens160 proto static metric 100 192.168.0.0/24 dev ens160 proto kernel scope link src 192.168.0.132 metric 100 #可以上网 [rootlocalhost system-connections]# ping qq.com PING qq.com (113.108.81.189) 56(84) 字节的数据。 64 字节来自 113.108.81.189: icmp_seq1 ttl128 时间61.3 毫秒 64 字节来自 113.108.81.189: icmp_seq2 ttl128 时间71.2 毫秒 64 字节来自 113.108.81.189: icmp_seq3 ttl128 时间69.3 毫秒 64 字节来自 113.108.81.189: icmp_seq4 ttl128 时间71.7 毫秒 64 字节来自 113.108.81.189: icmp_seq5 ttl128 时间69.7 毫秒 64 字节来自 113.108.81.189: icmp_seq6 ttl128 时间68.2 毫秒 ^C --- qq.com ping 统计 --- 已发送 7 个包 已接收 6 个包, 14.2857% packet loss, time 6004ms rtt min/avg/max/mdev 61.309/68.572/71.737/3.449 ms3.2 nmcli配置静态IP在 CentOS Stream 9 中网络管理已经完全转向由NetworkManager主导。nmcliNetworkManager Command Line Interface是其核心的命令行工具。相比传统的ifcfg脚本或ip addr命令nmcli的优势在于它的配置是持久化的重启不失效且能实时反映 NetworkManager 的状态。nmcli常用命令操作类型命令示例说明查看状态nmcli general status查看 NetworkManager 整体运行状态查看设备nmcli device status查看所有网卡及其连接状态查看连接nmcli connection show列出所有已保存的连接配置文件启用连接nmcli connection up ID激活指定的连接配置禁用连接nmcli connection down ID断开指定的连接重新加载nmcli connection reload修改配置文件后重新加载到内存修改网卡为静态IPIP地址配置为192.168.0.132。ipv4.addresses静态IP地址CIDR格式ipv4.gateway默认网关ipv4.dnsDNS服务器列表逗号分隔。[rootlocalhost ~]# nmcli connection modify ens33 \ ipv4.addresses 192.168.0.132/24 \ ipv4.gateway 192.168.0.2 \ ipv4.dns 223.5.5.5,8.8.8.8 \ ipv4.method manual激活配置。[rootlocalhost ~]# nmcli connection down ens33 sudo nmcli connection up ens33查看具体连接详情。[rootlocalhost ~]# nmcli connection show ens33四.centos9/centos10配置dnf/yum源4.1 dnf概述dnf (Dandified YUM)是基于 RPM 的 Linux 发行版的新一代软件包管理器专为 Fedora、RHEL 8 及 CentOS Stream 9/10 等系统设计作为yum 的直接替代品dnf 解决了 yum 的性能瓶颈和功能限制同时保持了类似的命令语法在 CentOS Stream 9/10 中yum 命令实际上是指向 dnf 的符号链接执行 yum 时实际调用的是 dnf 功能。[rootlocalhost ~]# ll -h /usr/bin/yum lrwxrwxrwx. 1 root root 5 2月16日 08:00 /usr/bin/yum - dnf-3 [rootlocalhost ~]# ll -h /usr/bin/dnf lrwxrwxrwx. 1 root root 5 2月16日 08:00 /usr/bin/dnf - dnf-34.2 dnf常用命令命令类型命令示例功能描述使用场景基础安装sudo dnf install package安装指定软件包安装新软件sudo dnf install package1 package2同时安装多个软件包批量安装sudo dnf install -y package自动确认安装无需交互自动化脚本软件包管理sudo dnf remove package卸载软件包移除不需要的软件sudo dnf update更新所有已安装的软件包系统升级sudo dnf update package更新特定软件包选择性更新sudo dnf autoremove自动清理不再需要的依赖系统精简查询与搜索dnf search keyword搜索软件包查找可用软件dnf info package查看软件包详细信息了解软件详情dnf provides /path/to/file查找提供特定文件的软件包问题排查dnf list installed列出所有已安装软件包系统审计仓库管理dnf repolist列出所有启用的仓库检查源配置dnf repolist --verbose显示仓库详细信息URL、状态等源问题排查sudo dnf config-manager --enable repo启用指定仓库添加新源sudo dnf config-manager --disable repo禁用指定仓库临时移除源缓存管理sudo dnf clean all清除所有缓存元数据和软件包解决缓存问题sudo dnf makecache重建缓存源更新后sudo dnf clean packages仅删除已下载的.rpm文件释放磁盘空间事务与历史dnf history查看所有操作记录审计系统变更dnf history info 5查看第5条记录的详细变更问题分析sudo dnf history undo 5撤销第5条操作系统回滚模块化功能dnf module list列出可用的模块查看多版本软件sudo dnf module enable php:8.0启用特定模块使用指定版本sudo dnf module install php安装模块化软件安装多版本软件高级功能dnf download package --resolve下载软件包及其依赖不安装离线安装准备sudo dnf install ./*.rpm安装本地下载的RPM包离线安装sudo dnf repair尝试自动修复系统解决软件包损坏问题4.3 配置dnf/yum源备份原先的repo文件。[rootlocalhost ~]# cd /etc/yum.repos.d/ [rootlocalhost yum.repos.d]# ls centos-addons.repo centos.repo [rootlocalhost yum.repos.d]# mkdir bak [rootlocalhost yum.repos.d]# mv *.repo bak/ [rootlocalhost yum.repos.d]# ls bak配置阿里云的yum源:ali-centos.repo 。[rootlocalhost yum.repos.d]# cat ali-centos.repo [baseos] nameCentOS Stream $releasever - BaseOS baseurlhttps://mirrors.aliyun.com/centos-stream/$stream/BaseOS/$basearch/os/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h countme1 enabled1 [baseos-debug] nameCentOS Stream $releasever - BaseOS - Debug baseurlhttps://mirrors.aliyun.com/centos-stream/$stream/BaseOS/$basearch/debug/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [baseos-source] nameCentOS Stream $releasever - BaseOS - Source baseurlhttps://mirrors.aliyun.com/centos-stream/$stream/BaseOS/source/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [appstream] nameCentOS Stream $releasever - AppStream baseurlhttps://mirrors.aliyun.com/centos-stream/$stream/AppStream/$basearch/os/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h countme1 enabled1 [appstream-debug] nameCentOS Stream $releasever - AppStream - Debug baseurlhttps://mirrors.aliyun.com/centos-stream/$stream/AppStream/$basearch/debug/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [appstream-source] nameCentOS Stream $releasever - AppStream - Source baseurlhttps://mirrors.aliyun.com/centos-stream/$stream/AppStream/$basearch/debug/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [crb] nameCentOS Stream $releasever - CRB baseurlhttps://mirrors.aliyun.com/centos-stream/$stream/CRB/$basearch/os/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h countme1 enabled1 [crb-debug] nameCentOS Stream $releasever - CRB - Debug baseurlhttps://mirrors.aliyun.com/centos-stream/$stream/CRB/$basearch/debug/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [crb-source] nameCentOS Stream $releasever - CRB - Source baseurlhttps://mirrors.aliyun.com/centos-stream/$stream/CRB/source/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0配置阿里云的yum源:ali-addons.repo 。[rootlocalhost yum.repos.d]# cat ali-addons.repo [highavailability] nameCentOS Stream $releasever - HighAvailability baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/HighAvailability/$basearch/os/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h countme1 enabled0 [highavailability-debug] nameCentOS Stream $releasever - HighAvailability - Debug baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/HighAvailability/$basearch/debug/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [highavailability-source] nameCentOS Stream $releasever - HighAvailability - Source baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/HighAvailability/source/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [nfv] nameCentOS Stream $releasever - NFV baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/NFV/$basearch/os/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h countme1 enabled0 [nfv-debug] nameCentOS Stream $releasever - NFV - Debug baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/NFV/$basearch/debug/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [nfv-source] nameCentOS Stream $releasever - NFV - Source baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/NFV/source/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [rt] nameCentOS Stream $releasever - RT baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/RT/$basearch/os/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h countme1 enabled0 [rt-debug] nameCentOS Stream $releasever - RT - Debug baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/RT/$basearch/debug/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [rt-source] nameCentOS Stream $releasever - RT - Source baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/RT/source/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [resilientstorage] nameCentOS Stream $releasever - ResilientStorage baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/ResilientStorage/$basearch/os/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h countme1 enabled0 [resilientstorage-debug] nameCentOS Stream $releasever - ResilientStorage - Debug baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/ResilientStorage/$basearch/debug/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [resilientstorage-source] nameCentOS Stream $releasever - ResilientStorage - Source baseurlhttp://mirrors.aliyun.com/centos-stream/$stream/ResilientStorage/source/tree/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0 [extras-common] nameCentOS Stream $releasever - Extras packages baseurlhttp://mirrors.aliyun.com/centos-stream/SIGs/$stream/extras/$basearch/extras-common/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512 gpgcheck1 repo_gpgcheck0 metadata_expire6h countme1 enabled1 [extras-common-source] nameCentOS Stream $releasever - Extras packages - Source baseurlhttp://mirrors.aliyun.com/centos-stream/SIGs/$stream/extras/source/extras-common/ gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512 gpgcheck1 repo_gpgcheck0 metadata_expire6h enabled0安装EPEL 仓库提供额外软件包。[rootlocalhost yum.repos.d]# dnf install epel-release [rootlocalhost yum.repos.d]# pwd /etc/yum.repos.d [rootlocalhost yum.repos.d]# ls ali-addons.repo ali-centos.repo bak epel.repo epel-testing.repo清除所有缓存元数据和软件包。[rootlocalhost ~]# dnf clean all重建缓存以及更新所有已安装的软件包[rootlocalhost ~]# dnf makecache [rootlocalhost ~]# dnf update