码迷,mamicode.com
首页 > 系统相关 > 详细

Linux的虚拟机拷贝到另外的操作系统时,NAT方式的静态IP无效,一直是获取的DHCP动态地址

时间:2015-05-26 06:46:35      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:

一、问题:
1、Linux虚拟机在A机的虚拟机中是NAT方式DHCP动态获取IP,设置了静态地址,IP地址不会发生变化,但是拷贝到B机上的虚拟机后,一直获取的时动态IP地址,无法得到静态IP。
2、执行/etc/init.d/network restart报错:
  1. [root@master init.d]# ./network restart
  2. 正在关闭接口 ens33 错误 : [/etc/sysconfig/network-scripts/ifdown-eth] 设备 具有 MAC 地址 00:00:00:00:00:00
  3. 00:0C:29:94:8E:A2,而不是配置的地址 00:0C:29:8B:9A:F2。忽略。
  4. [失败]
  5. 正在关闭环回接口: Could not load file ‘/etc/sysconfig/network-scripts/ifcfg-lo‘
  6. Could not load file ‘/etc/sysconfig/network-scripts/ifcfg-lo‘
  7. Could not load file ‘/etc/sysconfig/network-scripts/ifcfg-lo‘
  8. Could not load file ‘/etc/sysconfig/network-scripts/ifcfg-lo‘
  9. [ 确定 ]
  10. 正在打开环回接口: Could not load file ‘/etc/sysconfig/network-scripts/ifcfg-lo‘
  11. Could not load file ‘/etc/sysconfig/network-scripts/ifcfg-lo‘
  12. Could not load file ‘/etc/sysconfig/network-scripts/ifcfg-lo‘
  13. Could not load file ‘/etc/sysconfig/network-scripts/ifcfg-lo‘
  14. [ 确定 ]
  15. 正在打开接口 ens33 错误:没有找到可用于连接 ‘ens33‘ 的设备。
  16. [失败]
3、执行 systemctl restart network报错:
  1. Job for network.service failed. See "systemctl status network.service" and "journalctl -xe" for details.
4、执行journalctl -xe报错:
  1. 5 26 00:29:28 master /etc/sysconfig/network-scripts/ifdown-eth[1350]: 设备 具有 MAC 地址 00:00:00:00:00:00
  2. 00:0C:29:94:8E:A2,而不是配置的地址 00:0C:29:8B:9A:F2。忽略。
  3. 5 26 00:29:28 master NetworkManager[709]: <info> parsing /etc/sysconfig/network-scripts/ifcfg-lo ...
  4. 5 26 00:29:28 master NetworkManager[709]: <info> parsing /etc/sysconfig/network-scripts/ifcfg-lo ...
  5. 5 26 00:29:28 master NetworkManager[709]: <info> parsing /etc/sysconfig/network-scripts/ifcfg-lo ...
  6. 5 26 00:29:28 master NetworkManager[709]: <info> (lo): link disconnected
  7. 5 26 00:29:28 master NetworkManager[709]: <info> parsing /etc/sysconfig/network-scripts/ifcfg-lo ...
  8. 5 26 00:29:28 master NetworkManager[709]: <info> parsing /etc/sysconfig/network-scripts/ifcfg-lo ...
  9. 5 26 00:29:28 master NetworkManager[709]: <info> parsing /etc/sysconfig/network-scripts/ifcfg-lo ...
  10. 5 26 00:29:28 master NetworkManager[709]: <info> (lo): link connected
  11. 5 26 00:29:29 master NetworkManager[709]: <info> parsing /etc/sysconfig/network-scripts/ifcfg-lo ...
  12. 5 26 00:29:29 master NetworkManager[709]: <info> parsing /etc/sysconfig/network-scripts/ifcfg-lo ...
  13. 5 26 00:30:39 master systemd[1]: Configuration file /usr/lib/systemd/system/tog-pegasus.service is marked world-inaccessible. This has no effect as configuration data is acce
  14. 5 26 00:30:40 master systemd[1]: Configuration file /usr/lib/systemd/system/tog-pegasus.service is marked world-inaccessible. This has no effect as configuration data is acce
  15. 5 26 00:30:40 master systemd[1]: Configuration file /usr/lib/systemd/system/tog-pegasus.service is marked world-inaccessible. This has no effect as configuration data is acce
  16. 5 26 00:30:41 master systemd[1]: Configuration file /usr/lib/systemd/system/tog-pegasus.service is marked world-inaccessible. This has no effect as configuration data is acce
  17. 5 26 00:30:41 master systemd[1]: Configuration file /usr/lib/systemd/system/tog-pegasus.service is marked world-inaccessible. This has no effect as configuration data is acce
  18. 5 26 00:30:41 master systemd[1]: Configuration file /usr/lib/systemd/system/tog-pegasus.service is marked world-inaccessible. This has no effect as configuration data is acce
  19. 5 26 00:30:41 master systemd[1]: Configuration file /usr/lib/systemd/system/tog-pegasus.service is marked world-inaccessible. This has no effect as configuration data is acce
  20. 5 26 00:30:41 master systemd[1]: Configuration file /usr/lib/systemd/system/tog-pegasus.service is marked world-inaccessible. This has no effect as configuration data is acce
  21. 5 26 00:30:41 master systemd[1]: Configuration file /usr/lib/systemd/system/tog-pegasus.service is marked world-inaccessible. This has no effect as configuration data is acce
  22. 5 26 00:30:42 master systemd[1]: Configuration file /usr/lib/systemd/system/tog-pegasus.service is marked world-inaccessible. This has no effect as configuration data is acce
  23. 5 26 00:30:42 master systemd[1]: Configuration file /usr/lib/systemd/system/tog-pegasus.service is marked world-inaccessible. This has no effect as configuration data is acce
  24. 5 26 00:30:42 master systemd[1]: Configuration file /usr/lib/systemd/system/tog-pegasus.service is marked world-inaccessible. This has no effect as configuration data is acce
  25. 5 26 00:30:53 master NetworkManager[709]: <info> parsing /etc/sysconfig/network-scripts/ifcfg-lo ...
  26. 5 26 00:30:53 master network[1685]: 正在打开环回接口: Could not load file ‘/etc/sysconfig/network-scripts/ifcfg-lo‘
  27. 5 26 00:30:53 master NetworkManager[709]: <info> parsing /etc/sysconfig/network-scripts/ifcfg-lo ...
  28. 5 26 00:30:53 master network[1685]: Could not load file ‘/etc/sysconfig/network-scripts/ifcfg-lo‘
  29. 5 26 00:30:53 master NetworkManager[709]: <info> parsing /etc/sysconfig/network-scripts/ifcfg-lo ...
  30. 5 26 00:30:53 master network[1685]: Could not load file ‘/etc/sysconfig/network-scripts/ifcfg-lo‘
  31. 5 26 00:30:53 master NetworkManager[709]: <info> parsing /etc/sysconfig/network-scripts/ifcfg-lo ...
  32. 5 26 00:30:53 master network[1685]: Could not load file ‘/etc/sysconfig/network-scripts/ifcfg-lo‘
  33. 5 26 00:30:54 master network[1685]: [ 确定 ]
  34. 5 26 00:30:54 master network[1685]: 正在打开接口 ens33 错误:没有找到可用于连接 ‘ens33‘ 的设备。
  35. 5 26 00:30:54 master network[1685]: [失败]
  36. 5 26 00:30:54 master network[1685]: RTNETLINK answers: File exists
  37. 5 26 00:30:54 master network[1685]: RTNETLINK answers: File exists
  38. 5 26 00:30:54 master network[1685]: RTNETLINK answers: File exists
  39. 5 26 00:30:54 master network[1685]: RTNETLINK answers: File exists
  40. 5 26 00:30:54 master network[1685]: RTNETLINK answers: File exists
  41. 5 26 00:30:54 master network[1685]: RTNETLINK answers: File exists
  42. 5 26 00:30:54 master network[1685]: RTNETLINK answers: File exists
  43. 5 26 00:30:54 master network[1685]: RTNETLINK answers: File exists
  44. 5 26 00:30:54 master network[1685]: RTNETLINK answers: File exists
  45. 5 26 00:30:54 master systemd[1]: network.service: control process exited, code=exited status=1
  46. 5 26 00:30:54 master systemd[1]: Failed to start LSB: Bring up/down networking.
  47. -- Subject: Unit network.service has failed
  48. -- Defined-By: systemd
  49. -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
  50. --
  51. -- Unit network.service has failed.
  52. --
  53. -- The result is failed.
  54. 5 26 00:30:54 master systemd[1]: Unit network.service entered failed state.
  55. 5 26 00:30:54 master systemd[1]: network.service failed.
二、解决:
Linux虚拟机从A拷贝到B后,MAC地址发生改变,但是配置文件中并没有同步修改,导致此问题。
1、首先执行ifconfig查看新的MAC地址:
  1. ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  2. inet 192.168.130.109 netmask 255.255.255.0 broadcast 192.168.130.255
  3. inet6 fe80::20c:29ff:fe94:8ea2 prefixlen 64 scopeid 0x20<link>
  4. ether 00:0c:29:94:8e:a2 txqueuelen 1000 (Ethernet)
  5. RX packets 550 bytes 48524 (47.3 KiB)
  6. RX errors 0 dropped 0 overruns 0 frame 0
  7. TX packets 604 bytes 94343 (92.1 KiB)
  8. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  9. lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
  10. inet 127.0.0.1 netmask 255.0.0.0
  11. inet6 ::1 prefixlen 128 scopeid 0x10<host>
  12. loop txqueuelen 0 (Local Loopback)
  13. RX packets 8 bytes 800 (800.0 B)
  14. RX errors 0 dropped 0 overruns 0 frame 0
  15. TX packets 8 bytes 800 (800.0 B)
  16. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
可以看出ens33网卡对应的MAC地址为:00:0c:29:94:8e:a2,即ether对应的地址。
2、修改ens33网卡对应的MAC地址
vi /etc/sysconfig/network-scripts/ifcfg-ens33
  1. TYPE="Ethernet"
  2. DEFROUTE="yes"
  3. IPV4_FAILURE_FATAL="no"
  4. NAME="ens33"
  5. UUID="707084bc-d3aa-483f-878b-c93e6abf4a07"
  6. ONBOOT="yes"
  7. HWADDR="00:0C:29:8B:9A:F2"
  8. BOOTPROTO="static"
  9. NM_CONTROLLED="yes"
  10. IPADDR="192.168.130.101"
  11. NETMASK="255.255.255.0"
  12. GATEWAY="192.168.130.2"
将HWADDR改为00:0c:29:94:8e:a2即可。





Linux的虚拟机拷贝到另外的操作系统时,NAT方式的静态IP无效,一直是获取的DHCP动态地址

标签:

原文地址:http://www.cnblogs.com/bluejavababy/p/4529505.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!