linux使用:解决克隆虚拟机后UP BROADCAST RUNNING MULTICAST问题

在使用linux的过程中如果安装了多台虚拟机,并且每台虚拟机都是由上一台虚拟机克隆出来的我们可能会出现联网连不上的问题,在linux的控制台输出ifconfg会出现以下信息:

[root@tiny ~]$ ifconfig
eth2      Link encap:Ethernet  HWaddr 00:0C:29:FE:F8:14  
          inet6 addr: fe80::20c:29ff:fefe:f814/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:68 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:7385 (7.2 KiB)  TX bytes:2310 (2.2 KiB)
          Interrupt:19 Base address:0x2024 
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:480 (480.0 b)  TX bytes:480 (480.0 b)

会报 UP BROADCAST RUNNING MULTICAST错误。这是因为mac地址设置的问题,在这里提供一个解决办法:

1. 切换至root用户
由于相关文件只能由root进行修改,因此我们先应该转换为root用户启动

[admin@tiny ~]$ su root

2.查看当前MAC地址相关信息

[root@tiny rules.d]# cat /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:49:e9:9d", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x1022:0x2000 (vmxnet)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:13:e9:e2", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x1022:0x2000 (vmxnet)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:fe:f8:14", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

我们可以看到其中包含三块网卡信息分别是eth0,eth1,eth2,而我们使用eth2所以我们需要删除掉其他两块网卡信息。

[root@tiny rules.d]# vi /etc/udev/rules.d/70-persistent-net.rules
[root@tiny rules.d]# cat /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 (vmxnet)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:fe:f8:14", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

我们只留下eth2的网卡信息,我们记录下eth2的mac地址:00:0c:29:fe:f8:14

4. 修改ifcfg-eth2中的信息
在这里我发现了一件非常尴尬的事情,在/etc/sysconfig/network-scripts/文件夹下没有ifcfg-eth2

[root@tiny network-scripts]# ls /etc/sysconfig/network-scripts/
ifcfg-eth0~  ifdown-ippp    ifdown-tunnel  ifup-isdn    ifup-tunnel
ifcfg-eth1   ifdown-ipv6    ifup           ifup-plip    ifup-wireless
ifcfg-eth1~  ifdown-isdn    ifup-aliases   ifup-plusb   init.ipv6-global
ifcfg-lo     ifdown-post    ifup-bnep      ifup-post    net.hotplug
ifdown       ifdown-ppp     ifup-eth       ifup-ppp     network-functions
ifdown-bnep  ifdown-routes  ifup-ippp      ifup-routes  network-functions-ipv6
ifdown-eth   ifdown-sit     ifup-ipv6      ifup-sit

但是,我们可以拷贝一个

[root@tiny network-scripts]# mv /etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/network-scripts/ifcfg-eth2 

然后我们打开ifcfg-eth2

[root@tiny network-scripts]# cat /etc/sysconfig/network-scripts/ifcfg-eth2 
DEVICE=eth1
TYPE=Ethernet
UUID=eeb8ed32-3b4d-45c4-b2fe-9c7b5fe4e2ac
ONBOOT=yes
NM_CONTROLLED=yes
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth1"
HWADDR=00:0C:29:49:E9:9D
LAST_CONNECT=1488606798

BOOTPROTO=static
IPADDR=192.168.132.114
NETMASK=255.255.255.0
GATEWAY=192.168.132.1
DNS1=210.31.249.20

mac地址和在70-persistent-net.rules中的mac并不一样,我们将70-persistent-net.rules中的mac地址复制过来,并且将DEVICE和NAME也做相应的修改

[root@tiny network-scripts]# vi /etc/sysconfig/network-scripts/ifcfg-eth2 
[root@tiny network-scripts]# cat /etc/sysconfig/network-scripts/ifcfg-eth2 
DEVICE=eth2
TYPE=Ethernet
UUID=eeb8ed32-3b4d-45c4-b2fe-9c7b5fe4e2ac
ONBOOT=yes
NM_CONTROLLED=yes
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth2"
HWADDR=00:0c:29:fe:f8:14
LAST_CONNECT=1488606798

BOOTPROTO=static
IPADDR=192.168.132.115
NETMASK=255.255.255.0
GATEWAY=192.168.132.1
DNS1=210.31.249.20

5. 重启服务,并测试
重启network,查看网卡信息,并测试联网情况 。执行下面的命令:

[root@tiny network-scripts]# service network restart
正在关闭接口 eth2: 设备状态:3 (断开连接)
                                                           [确定]
关闭环回接口:                                             [确定]
弹出环回接口:                                             [确定]
弹出界面 eth2: 活跃连接状态:激活的
活跃连接路径:/org/freedesktop/NetworkManager/ActiveConnection/23
                                                           [确定]
[root@tiny network-scripts]# ifconfig
eth2      Link encap:Ethernet  HWaddr 00:0C:29:FE:F8:14  
          inet addr:192.168.132.115  Bcast:192.168.132.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fefe:f814/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1595 errors:0 dropped:0 overruns:0 frame:0
          TX packets:117 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:159465 (155.7 KiB)  TX bytes:33595 (32.8 KiB)
          Interrupt:19 Base address:0x2024 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:480 (480.0 b)  TX bytes:480 (480.0 b)
[root@tiny network-scripts]# ping 119.75.217.109
PING 119.75.217.109 (119.75.217.109) 56(84) bytes of data.
64 bytes from 119.75.217.109: icmp_seq=1 ttl=64 time=0.611 ms
64 bytes from 119.75.217.109: icmp_seq=2 ttl=64 time=0.261 ms
^C
--- 119.75.217.109 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1424ms
rtt min/avg/max/mdev = 0.261/0.436/0.611/0.175 ms

修改成功

posted on 2017-07-21 19:33  erygreat  阅读(1331)  评论(0编辑  收藏  举报

导航