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. JUnit-4.11使用报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing错误

    今天尝试使用JUnit,下载了最新的JUnit版本,是4.11,结果尝试使用发现总是报java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribi ...

  2. Linux下安装 TestLink常见问题解决方法

    Read/write permissions For security reason we suggest that directories tagged with [S] on following ...

  3. PMD使用手册

    文中测试例子均采用JHotDraw7源码,官网关于 JHotDraw的检测结果:http://pmd.sourceforge.net/reports/jhotdraw_JHotDraw.html 下载 ...

  4. JVM类载入过程及主动引用与被动引用

    了解类载入全过程,有助于了解JVM执行过程,以及更深入了解java动态性(解热部署,动态载入),提高程序灵活性. 类载入全过程: JVM将class文件字节码文件载入到内存中.并对数据进行校验解析和初 ...

  5. HDU 4288 线段树+离散化

    题意: n个操作 在[1, 100000]  的区间上add 或del数( 必不会重复添加或删除不存在的数) sum 求出整个集合中 (下标%5 == 3 位置) 的数   的和 注意数据类型要64位 ...

  6. gitlab 启动参考

    第一步 启动gitlab bundle exec rails s -e production -d 第二步 启动redis /etc/init.d/redis start chkconfig redi ...

  7. APUE16章的运行示例16-14

    参考文章:http://blog.csdn.net/andyxie407/article/details/1672325 今天在运行在APUE第16章的16-14(客户端)和16-15(服务端)遇到了 ...

  8. 常用mimetype

    $mimetypelist["csm"] = "application/cu-seeme";$mimetypelist["cu"] = &q ...

  9. [转] 用实例给新手讲解RSA加密算法

    http://www.cfca.com.cn/zhishi/wz-012.htm PS: 通常公钥对数据加密,私钥对数据解密:私钥对数据签名,公钥对数据签名进行认证 RSA加密算法是最常用的非对称加密 ...

  10. Java基础知识强化之集合框架笔记19:List集合迭代器使用之 并发修改异常的产生原因 以及 解决方案

    1. 我有一个集合,如下,请问,我想判断里面有没有"world"这个元素,如果有,我就添加一个"javaee"元素,请写代码实现. ConcurrentModi ...