解决克隆虚拟机后UP,Linux系统网卡设置教程

By admin in 美高梅手机版4858 on 2019年4月26日

在运用linux的进程中如若设置了多台虚拟机,并且每台虚拟机都以由上壹台虚拟机克隆出来的大家可能晤面世联网连不上的主题素材,在linux的操纵台出口ifconfg会油可是生以下音信:

解决克隆虚拟机后UP,Linux系统网卡设置教程。在选用linux的进程中要是设置了多台虚拟机,并且每台虚拟机都以由上①台虚拟机克隆出来的大家兴许会冒出联网连不上的难题,在linux的支配台出口ifconfg会并发以下新闻:

事先在合营社提供的虚构机器上边,平素有个难题用着很不舒服,为何它的IP选取的设施的eth二的,可是笔者在/etc/sysconfig/network-scrpts/上边也远非找到ifcfg-eth二的安顿文件,那样子,作者就无可如何改动IP了,也无奈使用静态IP了,每一次都以虚拟机动态分配的IP,那些太劳顿了。有时光化解了下这些题目。首先自个儿注解下,笔者那边是用的NAT的方法与主机相连的。其实本身到方今也还未曾弄精晓,为何平素不eth2的布置文件,那种情状下
笔者该怎么去修改IP,然则本身想那几个自然跟现成的网卡有关,也便是跟现在的mac地址有关联,因为作者化解地方的尤其标题根本是透过mac出发的。
经查明,Linux是用/etc/network/interfaces那一个布局文件来载入网卡的。私下认可配置中,它提醒Linux会自动物检疫索eth0网卡,并机关分配IP。但是,当虚拟网卡的MAC地址更改后,网卡在Linux中不是eth0了,而是eth一或任何值。因而才会找不到。而现成系统中,有哪些网卡是可用的,能够因此上面包车型大巴吩咐查看:
ifconfig -a
选拔那么些命令后当真,发掘每刷新一回mac地址,就生成贰个新的eth。
在Linux中,还有二个配置文件:/etc/udev/rules.d/70-persistent-net.rules,张开那些布局文件后,会开采里面列出了独具Linux找到的网卡,包含历史的。因而,化解无法加载网卡的难题就有多个消除办法:
一.改造interfaces配置文件,使其选择新型的eth网卡
2.删除.rules文件,让linux重新将网卡以为是eth0
自家找了下interfaces那些文件未有找到,于是小编选择了第3个情势,删除rules配置文件,让他再次选择网卡。重启机器之后,敲了ifconfig,出现的不再是eth贰了,但是选择的以至是eth一了,
那又让自身隐隐了,怎么会形成是eth一了吧? 同时
也一向不发现eth一的安插文件,那样子,小编也许迫于调节IP啊。小编查看了下ifconfig命令中的mac地址和ifcfg-eth0中的mac地址相比下,开采多头的mac地址不均等,使用/etc/init.d/network
restart
重启网卡,居然报eth0没有这么些装置,因此剖断,eth0配置文件中的mac地址是漏洞百出,于是把eth0配文件中的mac地址改成了ifocnfig中出来的mac地址,然后再次删除/etc/udev/rules.d/70-persistent-net.rules文件,重启机器,让他再一次重复选拔网卡,运维现在,查看了ifocnfig,那时候变成了eth0,看来是例行了,然后修改下ifcfg-eth0的ip,重启网络服务,未有报错,符合规律,查看下IP,改过来了,OK,1切不荒谬。
此刻又发现新主题材料了,笔者在那几个虚拟机中常识去访问主机所在网段的机械时,居然报:network
unreachable,肯定是网关的主题素材,查看下网关,果然未有设置,在极端是命令:arp
-a ,查看本机器的网关,然后修改ifgcfg-eth0,重启服务器,OK,消除!

是因为做了虚拟机的仿造,发掘克隆机和被克隆机的MAC地址同样了,下边作者快要介绍一下linux中网卡的布置步骤,作者使用的linux是CentOS
release 6.九 (Final)

[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)
[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)

壹、root用户编辑/etc/udev/rules.d/70-persistent-net.rules文件,找到mac地址重复的格外网卡并剔除(那里是eth0),记住新生成的网卡eth一的mac地址,前面会用到,保存并脱离

会报 UP BROADCAST RUNNINGMULTICAST错误。那是因为mac地址设置的主题材料,在那边提供一个消除办法:

会报 UP BROADCAST RUNNIN克林霉素ULTICAST错误。那是因为mac地址设置的难点,在此间提供1个化解办法:

# vi
/etc/udev/rules.d/70-persistent-net.rules

1. 切换至root用户
美高梅手机版4858,由于有关文书只好由root进行改造,由此大家先应该转换为root用户运行

1. 切换至root用户
由于有关文书只好由root进行修改,由此我们先应该转变为root用户运行

美高梅手机版4858 1

[admin@tiny ~]$ su root
[admin@tiny ~]$ su root

二、编辑/etc/sysconfig/network-scripts/ifcfg-eth0,将HWADD奥迪Q3地址改为步骤第11中学新变迁的mac地址00:50:5六:3陆:1陆:7二

贰.翻看当前MAC地址相关音讯

2.翻看当前MAC地址相关音讯

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

[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"
[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"

美高梅手机版4858 2

我们得以见见个中饱含3块网卡新闻分别是eth0,eth一,eth贰,而笔者辈选择eth贰所以我们须要删除掉别的两块网卡消息。

作者们能够见见里边累积叁块网卡音信分级是eth0,eth一,eth2,而作者辈使用eth二所以大家须求删除掉其余两块网卡新闻。

三、重启系统,使前边的修改生效

[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"
[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"

# reboot

笔者们只留下eth二的网卡音讯,我们记录下eth二的mac地址:00:0c:29:fe:f8:14

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

如上就是本文的全体内容,希望对大家的学习抱有帮忙,也希望我们多多援救脚本之家。

四. 改变ifcfg-eth第22中学的消息
在此地笔者发觉了壹件越发狼狈的业务,在/etc/sysconfig/network-scripts/文件夹下未有ifcfg-eth二

四. 修改ifcfg-eth第22中学的音信
在那里作者意识了1件13分难堪的事务,在/etc/sysconfig/network-scripts/文本夹下未有ifcfg-eth二

您或许感兴趣的篇章:

  • linux 网卡配置详解及实例
  • 详解Linux查看实时网卡流量的三种艺术
  • Linux学习之CentOS(二十玖)–Linux网卡高档命令、IP外号及多网卡绑定的格局
  • ubuntu
    (linux)修改网卡名称命令
  • Linux服务器网卡流量查看方法
    shell和Python各壹枚
  • php获取网卡的MAC地址支持WIN/LINUX系统
  • 自动生成linux网卡配置脚本分享
  • linux系统单网卡绑定双IP的具体操作方法
  • linux
    双网卡绑定网络设置格局
  • Linux系统下双网卡配置实行总括
[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]# 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

可是,我们得以拷贝3个

只是,大家得以拷贝叁个

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

接下来我们张开ifcfg-eth贰

下一场大家开垦ifcfg-eth二

[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
[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也做相应的修改

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
[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

伍. 重启服务,并测试
重启network,查看网卡新闻,并测试联网状态 。实施上边包车型客车吩咐:

伍. 重启服务,并测试
重启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
[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

修改成功

修改成功

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 美高梅手机版4858 版权所有