在使用VMware Workstation Pro的克隆虚拟机遇到问题“Device eth0 has different MAC address than expected, ignoring.” 系统:CentOS7
service network restart //重启网络服务
Restarting network (via systemctl): Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details. [FAILED]
发现异常了,查看一下日志
cat /var/log/messages //查看日志
Jun 18 12:04:54 localhost network: Bringing up interface Wired_connection_1: ERROR : [/etc/sysconfig/network-scripts/ifup-eth] Device has different MAC address than expected, ignoring.
Jun 18 12:04:54 localhost /etc/sysconfig/network-scripts/ifup-eth: Device has different MAC address than expected, ignoring
Jun 18 12:04:54 localhost network: [FAILED]
Jun 18 12:04:54 localhost network: Bringing up interface eth0: RTNETLINK answers: File exists
Jun 18 12:05:06 localhost PackageKit: uid 0 is trying to obtain org.freedesktop.packagekit.system-sources-refresh auth (only_trusted:0)
Jun 18 12:05:06 localhost PackageKit: uid 0 obtained auth for org.freedesktop.packagekit.system-sources-refresh
Jun 18 12:05:07 localhost kernel: TCP: lp registered
Jun 18 12:05:15 localhost network: [ OK ]
Jun 18 12:05:15 localhost network: RTNETLINK answers: File exists
Jun 18 12:05:15 localhost network: RTNETLINK answers: File exists
Jun 18 12:05:15 localhost network: RTNETLINK answers: File exists
Jun 18 12:05:15 localhost network: RTNETLINK answers: File exists
Jun 18 12:05:15 localhost network: RTNETLINK answers: File exists
Jun 18 12:05:15 localhost network: RTNETLINK answers: File exists
Jun 18 12:05:15 localhost network: RTNETLINK answers: File exists
Jun 18 12:05:15 localhost network: RTNETLINK answers: File exists
Jun 18 12:05:15 localhost network: RTNETLINK answers: File exists
Jun 18 12:05:15 localhost systemd: network.service: control process exited, code=exited status=1
Jun 18 12:05:15 localhost systemd: Failed to start LSB: Bring up/down networking.
Jun 18 12:05:15 localhost systemd: Unit network.service entered failed state.
Jun 18 12:05:15 localhost systemd: network.service failed.
发现第二行有mac地址有问题
vi /etc/sysconfig/network-scripts/ifup-eth //查看一下这个脚本
### 找出黄色部分Device has different MAC address than expected
> if [ -n "${HWADDR}" ]; then
FOUNDMACADDR=$(get_hwaddr ${REALDEVICE})
if [ "${FOUNDMACADDR}" != "${HWADDR}" -a "${FOUNDMACADDR}" != "${MACADDR}" ]; then
net_log $"Device ${DEVICE} has different MAC address than expected, ignoring."
exit 1
fi
fi
发现这个是判断MAC地址的一个语句 打印一下要判断的语句为什么MAC不等于,修改一下
if [ -n "${HWADDR}" ]; then
FOUNDMACADDR=$(get_hwaddr ${REALDEVICE})
if [ "${FOUNDMACADDR}" != "${HWADDR}" -a "${FOUNDMACADDR}" != "${MACADDR}" ]; then
net_log $"Device ${DEVICE} has different MAC address than expected, ignoring."
net_log $"==============start======================="
net_log $"!!!!${FOUNDMACADDR}" != "${HWADDR}" -a "${FOUNDMACADDR}" != "${MACADDR}!!!!!"
net_log $"start.FOUNDMACADDR=${FOUNDMACADDR} - HWADDR=${HWADDR} - MACADDR=${MACADDR}.end"
net_log $"===============ent========================"
exit 1
fi
fi
service network restart //重启网络服务 cat /var/log/messages //查看日志
start.FOUNDMACADDR=00:00:00:00:00:00#01200:50:56:25:F1:F1#01252:54:00:C6:E8:77#01252:54:00:C6:E8:77 - ==HWADDR=00:0C:29:EB: D7:BF== - MACADDR=.end
发现这个读取的HWADDR和我修改的/etc/sysconfig/network-scripts/ifcfg-eth0 配置的不一样,而且和克隆机的MAC居然是一样不太理解,网上都是说改了这个ifcfg-eth0这个配置文件得MAC地址就好了,我改了一直报错,所以我测试把HWADDR=00:0C:29:EB: D7:BF这个读取的MAC改成ifcfg-etho的MAC地址试试
ifcfg-eth0
MACADDR=0:0c:29:eb:d7:bf
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth0
DEVICE=eth0
ONBOOT=yes
DNS1=8.8.8.8
IPADDR=192.168.1.109
PREFIX=24
GATEWAY=192.168.1.1
NM_CONTROLLED=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_PRIVACY=no
###虚拟机关闭 设置网络适配器(本人用的是桥接模式)-高级-MAC地址改成0:0c:29:eb:d7:bf 重启
service network restart //重启网络服务
[root[@localhost](https://my.oschina.net/u/570656) network-scripts]# service network restart
Restarting network (via systemctl): [ OK ]