Centos8使用network管理网络

前言:

在CentOS8中,我们常用的network.service服务就被NetworkManager.service服务代替了,同样的,IP的配置方法也发生了改变,那么如果想使用network.service服务去管理/配置系统网络怎么办呢?下面带你梦回network.service

一、安装network-scripts

静默安装(-q)

1
dnf install -y  network-scripts

安装过程:

1
2
3
4
5
6
7
[root@localhost ~]# dnf install -y -q network-scripts
警告:/var/cache/dnf/BaseOS-929b586ef1f72f69/packages/network-scripts-10.00.6-1.el8_2.1.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID 8483c65d: NOKEY
导入 GPG 公钥 0x8483C65D:
Userid: "CentOS (CentOS Official Signing Key) <security@centos.org>"
指纹: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
来自: /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[root@localhost ~]#

此时,服务安装完成了,接下来开始启用该服务

二、启用network

1
2
3
systemctl start network
systemctl enable network
systemctl status network

三. 禁用NetworkManager.service

1
2
3
4
5
6
7
8
systemctl stop NetworkManager
systemctl disable NetworkManager
执行结果:
[root@localhost ~]# systemctl stop NetworkManager
[root@localhost ~]# systemctl disable NetworkManager
Removed /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
Removed /etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service.

到这里,NetworkManager服务就停止工作了,这时候可以先安装network-scripts(也就是network.service)了

四、卸载NetworkManager(可选 建议保留)

执行卸载命令:

1
dnf remove -y NetworkManager

效果

https://github.com/zznn-cloud/zznn-cloud-blog-images/raw/main/Qexo/24/5/image_a6a352e2ac83bc5373276f96402b5ff4.png

本文参考

https://blog.csdn.net/qq_36154886/article/details/109839926