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

CentOS 7 - Not Getting IP Address After Reboot

· 52CE 我爱测

I can't quite seem to figure out why. Seems very odd. Setup; DHCP/Static IP Managed on Router/Firewall VM with CentOS 7 Installed that ultimately gets IP address from above Seems that whenever I reboot the VM, I have to run the c…

问题原文

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

I can't quite seem to figure out why. Seems very odd.

Setup;

  • DHCP/Static IP Managed on Router/Firewall
  • VM with CentOS 7 Installed that ultimately gets IP address from above

Seems that whenever I reboot the VM, I have to run the command dhclient for the VM to pick up the IP address and start working.

What gives? Usually this stuff just works out of the box, not sure what is going on here.

For added context, I've got the CentOS 7 VM configured as DHCP, and on the firewall it's configured for MAC ID XYZ = Static IP 1.2.3.4 so that I can keep the management of this simple. I don't want to go having to manage static IPs at the VM level as the VM should just accept whatever IP it is given from DHCP/Static as appropriate.

Feels like I'm missing something blindingly obvious here that is getting in the way of basic behaviour.

Update Turns out that the default when installing Cent OS 7 and configuring the network on the installation screen is that this results in the default line in the file, /etc/sysconfig/network-scripts/ifcfg-eth0 is

ONBOOT=no

So I just changed that and it's working now as expected. Odd for CentOS 7 to default to not connecting to a network automatically on boot.

已采纳解答

原帖链接 · asktyagi · CC BY-SA 4.0

Edit your interface config file /etc/sysconfig/network-scripts/ifcfg-ethX Make sure config is similar to below.

DEVICE=ethX
BOOTPROTO=dhcp
ONBOOT=yes

I Guess BOOTPROTO=dhcp might be missing.

Please feel free to update question if doesn't work

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

资料来源与适用范围

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

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

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