kvm 虚拟机 复制之后 默认网卡是 eth2了

用 ifconfig -a 命令查看所有的网络设置,果然没有eth0的相关设置,多出来一个eth2。显示如下:
[root@neal ~]# ifconfig -a
eth2      Link encap:Ethernet  HWaddr 52:54:00:A0:10:38  
          inet addr:192.168.1.226  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fea0:1038/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:11764 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5302 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1361989 (1.2 MiB)  TX bytes:428860 (418.8 KiB)
          Interrupt:11 Base address:0x2000

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:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

virbr0    Link encap:Ethernet  HWaddr 52:54:00:4F:C2:A3  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:473 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:49932 (48.7 KiB)

virbr0-nic Link encap:Ethernet  HWaddr 52:54:00:4F:C2:A3  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
由于系统默认的启动网卡是eth0,所以怎么样把eth2更改为eth0成了当务之急。查了很多资料最终终于找到解决方法,方法如下:

修改文件vi /etc/udev/rules.d/70-persistent-net.rules 文件,原来为:
vi /etc/udev/rules.d/70-persistent-net.rules 

[root@neal ~]# 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 0x1af4:0x1000 (virtio-pci)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:57:05:8f", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x10ec:0x8139 (8139cp)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:9b:af:6b", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x10ec:0x8139 (8139cp)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:a0:10:38", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
修改后:

[root@neal ~]# 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 0x1af4:0x1000 (virtio-pci)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:57:05:8f", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

# PCI device 0x10ec:0x8139 (8139cp)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:9b:af:6b", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x10ec:0x8139 (8139cp)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:a0:10:38", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

保存重启后可以看到原来的网络配置又回来了。

转载自:http://hi.baidu.com/li_zhonghui/item/71e4ed52f1f92c15da163596

把centos 网卡接口eth2改成eth0的更多相关文章

  1. Centos7修改默认网卡名(改为eth0)以及网卡启动报错RTNETLINK answers: File exists处理

    安装好centos7版本的系统后,发现默认的网卡名字有点怪,为了便于管理,可以手动修改.下面对centos7版本下网卡重命名操作做一记录:1)编辑网卡信息[root@linux-node2~]# cd ...

  2. Saltstack把网卡从ens160修改成eth0

    手动修改参考:https://www.cnblogs.com/minseo/p/8521873.html salt目录结构为 files/grub GRUB_TIMEOUT=5 GRUB_DISTRI ...

  3. Centos7下修改默认网卡名(改为eth0)的操作记录

    安装好centos7版本的系统后,发现默认的网卡名字有点怪,为了便于管理,可以手动修改.下面对centos7版本下网卡重命名操作做一记录:1)编辑网卡信息[root@linux-node2~]# cd ...

  4. 将Ubuntu下网卡名称enss改为eth0

    将Ubuntu下网卡名称enss改为eth0   sudo nano /etc/default/grub 找到GRUB_CMDLINE_LINUX=""改为GRUB_CMDLINE ...

  5. CentOS 7将网卡名称eno16777736改为eth0

    http://www.linuxidc.com/Linux/2015-09/123396.htm Linux系统版本:CentOS_7(64位) 一.前言: 今天将CentOS 6.5装回了CentO ...

  6. Linux学习之CentOS(三)----将Cent0S 7的网卡名称eno16777736改为eth0

    [声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/3 ...

  7. 把CentOS 7.x网卡名称eno16777736改为eth0

    CentOS 7.x系统中网卡命名规则被重新定义,可能会是"eno167777xx"等,下面我们把网卡名称改为eth0这种. 一.cd  /etc/sysconfig/networ ...

  8. Ubuntu中将网卡名称eno16777736改回eth0

    一.前言 今天在Vmware Workstation中安装了Ubuntu Server 15.10,然后发现网卡名称出现了问题,主网卡竟然不叫“eth0”,而是叫一个奇怪的名字“eno16777736 ...

  9. 将Cent0S 7的网卡名称eno16777736改为eth0

    新建的虚拟机redhat linux7默认的网卡名称是eno16777736,找不到eth0如图所示: 修改网卡名称: 输入如下命令,进入对应目录,编辑文件: vim /etc/sysconfig/g ...

随机推荐

  1. 听听Matt Rogish说怎么面试程序员

    Google的人力运营高级副总裁Laszlo Bock在一次采访中说Google发现在面试程序员时问智力题完全是浪费时间,Matt Rogish在他的这篇博客How to Interview Prog ...

  2. SVN太旧,要更新问题

    同步或者提交的时候出现问题提示 The working copy needs to be upgradedsvn: Working copy 'E:\JAVA\Workspaces\uhr' is t ...

  3. [转]Animation 动画详解(一)——alpha、scale、translate、rotate、set的xml属性及用法

    转载:http://blog.csdn.net/harvic880925/article/details/39996643 前言:这几天做客户回访,感触很大,用户只要是留反馈信息,总是一种恨铁不成钢的 ...

  4. zTree实现地市县三级级联报错(一)

    zTree实现地市县三级级联 1.详细报错例如以下: java.lang.IllegalStateException: Failed to load ApplicationContext at org ...

  5. [转] 「指尖上的魔法」 - 谈谈 React Native 中的手势

    http://gold.xitu.io/entry/55fa202960b28497519db23f React-Native是一款由Facebook开发并开源的框架,主要卖点是使用JavaScrip ...

  6. Struts2 result type

    Struts2支持的不同类型的返回结果为: type name 说明 dispatcher 缺省类型,用来转向页面,通常处理JSP chain 转向另一个action,用来处理Action链 redi ...

  7. Linux下长时间ping网络加时间戳并记录到文本(转)

    [root@test ~]# ping 192.168.2.1 -c 10 PING 192.168.2.1 (192.168.2.1) 56(84) bytes of data.64 bytes f ...

  8. Linux yum命令重装mysql

    如果是 rpm 安装的话,可以用 rpm -e mysql-server 如果是yum安装的,可以用 yum remove mysql* 删除MySQL安装文件夹 然后使用yum安装mysql: 1. ...

  9. poj 1821 Fence 单调队列优化dp

    /* poj 1821 n*n*m 暴力*/ #include<iostream> #include<cstdio> #include<cstring> #incl ...

  10. PHP 解决时差8小时的问题

    有时候用php echo date("Y-m-d H:i:s")的时候会发现自己的时间和系统时间有差别 这里问题一般就是因为你自己的时区和配置的时区出现了差别的原因: 解决办法有三 ...