大网数据广告活动
服务器运维问答

Steps to assign static IP address in CentOS Linux via command line?

· 52CE 我爱测

How to configure so the Linux CentOS v8 VM I have with static IP address? I have already set the networking parameter during the GUI installation, but after the reboot, it still reverting back with DHCP IP addressing? Do I have t…

问题原文

原帖链接 · Senior Systems Engineer · CC BY-SA 4.0

How to configure so the Linux CentOS v8 VM I have with static IP address?

I have already set the networking parameter during the GUI installation, but after the reboot, it still reverting back with DHCP IP addressing?

Do I have to create a new interface file rather than modifying the below:

 cat /etc/sysconfig/network-scripts/ifcfg-ens192

Note: I cannot even restart the network service as mentioned in the various blog:

[root@PRDSIEM01-VM etc]# systemctl restart network
Failed to restart network.service: Unit network.service not found.

社区高分解答

原帖链接 · Michael Hampton · CC BY-SA 4.0

By default, networking on CentOS 7 and 8 is managed by NetworkManager.

It uses a plugin called ifcfg-rh to read the old network service configuration files (used in CentOS 6 and previous versions) such as the one you mentioned and translate them into the appropriate NetworkManager configuration.

What has probably happened here is that the interface name has changed from what it was during installation. This often happens with virtual machines running under VMware products. It looks like you had the interface name ens192 at install time. You can use ip link to see the current interface name.

If the name differs, you can edit the file and change the interface name within, then reload NetworkManager.

[root@PRDSIEM01-VM ~]# systemctl reload NetworkManager 

While NetworkManager excels at managing networks for desktop/laptop systems, and certainly works for servers, it's quite heavy for that purpose. I've lately begun switching my CentOS 8 servers to the much lighter systemd-networkd, which is a bit better integrated into the system, but doesn't support desktop/laptop systems (particularly WiFi) as well. You might consider doing the same.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-08-12)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。