Vmware 克隆CentOS 网络IP配置

本文介绍了解决CentOS系统中因网卡名称变更导致的网络配置问题。通过修改配置文件中的网卡名称和MAC地址,重启网络服务,最终实现网络连接恢复正常。适用于VMware环境下克隆出的CentOS实例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在VMware里克隆出来的CentOS Linux。。

ifconfig...没有看到eth0.。然后重启网卡又报下面错误。

故障现象:

service network restart
Shutting down loopback insterface:                                                                                                     [  OK  ]
Bringing up loopback insterface:                                                                                                          [  OK  ]
Bringing up interface eth0:  Device eth0 does not seem to be present,delaying initialization.                    [FAILED]

解决办法:

1.查看新添加的网卡的MAC
方法1:打开/etc/udev/rules.d/70-persistent-net.rules内容如下面例子所示:

# vi /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:8f:89:9
7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:50:bd:1
7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

记录下,eth1网卡的mac地址00:0c:29:50:bd:17

方法2:

编辑虚拟机,查看网络适配器,虚拟机部署完成都会生成一个MAC.



2. 接下来,打开/etc/sysconfig/network-scripts/ifcfg-eth0

# vi /etc/sysconfig/network-scripts/ifcfg-eth0

将 DEVICE="eth0"  改成  DEVICE="eth1"  ,
将 HWADDR="00:0c:29:8f:89:97" 改成上面的mac地址  HWADDR="00:0c:29:50:bd:17"

3. 最后,重启网络

# service network restart
或者

# /etc/init.d/network restart

正常了

 

特殊情况下,需要网关不在同一个网段,需要做下面的操作:

vim /etc/rc.local

route add -host 10.34.52.1 eth2                 #添加静态路由

route add default gw 10.34.52.1

保存后退出。重启机器。

 

开机后,可使用route 命令查看默认网关是否配置成功。

ping 网关可以正常ping通,就表示配置成功~

 

转载于:https://www.cnblogs.com/yu2000/p/3784534.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值