一.问题说明

测试环境中出现的小问题,因为虚拟机之间经常复制来复制去,导致网卡配置这块的不一致现象。

配置文件的信息:

[root@ora10g network-scripts]# catifcfg-eth0

DEVICE="eth0"

NM_CONTROLLED="yes"

ONBOOT=yes

TYPE=Ethernet

BOOTPROTO=none

IPADDR=192.168.1.12

PREFIX=24

GATEWAY=192.168.1.1

DEFROUTE=yes

IPV4_FAILURE_FATAL=no

IPV6INIT=no

NAME="System eth0"

UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03

HWADDR=08:00:27:BD:A6:ED

[root@ora10g network-scripts]# catifcfg-eth1

DEVICE="eth1"

NM_CONTROLLED="yes"

ONBOOT=yes

TYPE=Ethernet

BOOTPROTO=none

IPADDR=192.168.1.13

PREFIX=24

GATEWAY=192.168.1.1

DNS1=8.8.8.8

DEFROUTE=yes

IPV4_FAILURE_FATAL=yes

IPV6INIT=no

NAME="System eth1"

UUID=9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04

HWADDR=08:00:27:6E:86:10

这里对应的是网卡名称是eth0和eth1.

但是如果我们使用ifconfig 命令查看:

[root@ora10g network-scripts]# ifconfig -a

eth2     Link encap:Ethernet  HWaddr08:00:27:BD:A6:ED

inet addr:192.168.1.12 Bcast:192.168.1.255 Mask:255.255.255.0

inet6 addr: fe80::a00:27ff:febd:a6ed/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500  Metric:1

RX packets:187 errors:0 dropped:0 overruns:0 frame:0

TX packets:59 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:16356 (15.9 KiB)  TXbytes:6116 (5.9 KiB)

eth3     Link encap:Ethernet  HWaddr08:00:27:6E:86:10

inet addr:192.168.1.13 Bcast:192.168.1.255 Mask:255.255.255.0

inet6 addr: fe80::a00:27ff:fe6e:8610/64 Scope:Link

UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

RX packets:1357 errors:0 dropped:0 overruns:0 frame:0

TX packets:1099 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:120604 (117.7 KiB)  TXbytes:115937 (113.2 KiB)

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)  TXbytes:480 (480.0 b)

这里的网卡名称是eth2和eth3.

二.解决方法

修改 /etc/udev/rules.d/70-persistent-net.rules文件中的映射关系就可以了。

--修改之前:

[root@ora10g network-scripts]# cat/etc/udev/rules.d/70-persistent-net.rules

# This file was automatically generated bythe /lib/udev/write_net_rules

# program, run by thepersistent-net-generator.rules rules file.

#

# You can modify it, as long as you keepeach rule on a single

# line, and change only the value of theNAME= key.

# PCI device 0x8086:0x100e (e1000)

SUBSYSTEM=="net",ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:d4:ab:67",ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x8086:0x100e (e1000)

SUBSYSTEM=="net",ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:af:2b:37",ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100e (e1000)

SUBSYSTEM=="net",ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:bd:a6:ed",ATTR{dev_id}=="0x0", ATTR{type}=="1",KERNEL=="eth*", NAME="eth2"

# PCI device 0x8086:0x100e (e1000)

SUBSYSTEM=="net",ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:6e:86:10",ATTR{dev_id}=="0x0", ATTR{type}=="1",KERNEL=="eth*", NAME="eth3"

--修改之后:

[root@ora10g network-scripts]# cat/etc/udev/rules.d/70-persistent-net.rules

# This file was automatically generated bythe /lib/udev/write_net_rules

# program, run by thepersistent-net-generator.rules rules file.

#

# You can modify it, as long as you keepeach rule on a single

# line, and change only the value of theNAME= key.

# PCI device 0x8086:0x100e (e1000)

SUBSYSTEM=="net",ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:6E:86:10",ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x8086:0x100e (e1000)

SUBSYSTEM=="net",ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:BD:A6:ED",ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

注意这里的MAC地址要和ifcfg-eth0 保持一致。

然后重启一下网卡和udev:

--ifdown 网卡:

ifdown eth0

ifdown eth1

--重启udev

/etc/init.d/udev-post stop;

/etc/init.d/udev-post start

或者使用:

service udev-post stop
service udev-post start

注意: 对与Oracle linux 是udev-post, 而redhat 是udev

--ifup:

Ifup eth0

Ifup eth1

不过在我的测试中,这2个都没有效果,我是把整个OS都重启了,才生效的。 小知识,随笔记之。

CentOS修改网卡名称的更多相关文章

  1. centos 6 网卡名称修改

    centos6 中网卡的名字有时不是eth0,这时就会带来诸多不便,为此需要修改网卡的名称. 修改网卡名称vim /etc/sysconfig/network-scripts/ifcfg-eno167 ...

  2. CentOS 7.2修改网卡名称

    #!/bin/bash #Centos7.2修改网卡名称ens33为eth0 #2017/05/19 if [ -f /etc/sysconfig/grub ];then cd cp /etc/sys ...

  3. linux修改网卡名称

    本文转载自江一<linux修改网卡名称> 终端输入:vi /etc/udev/rules.d/70-persistent-net.rules 出现以下文件 # This file was ...

  4. Linux修改网卡名称、主机名

    Linux修改网卡名称.主机名 环境:VirtualBox 5.0.14 + RHEL 6.5 需求:个人实验搭建一套Standby RAC时,为了节约时间,直接复制之前安装RAC的主机模板. 但复制 ...

  5. ubuntu修改网卡名称ensX为eth0

    1.sudo nano /etc/default/grub 找到GRUB_CMDLINE_LINUX="" 改为GRUB_CMDLINE_LINUX="net.ifnam ...

  6. Ubuntu20 修改网卡名称

    Ubuntu 修改网卡名称 Ubuntu修改网卡名称 Ubuntu 版本: Ubuntu 20.04 查看当前网卡名称 root@it:~# ip add 1: lo: <LOOPBACK,UP ...

  7. CentOS 7修改网卡名称

    CentOS 7 修改网卡名为eth0 标签: linux 笔者Q:972581034 交流群:605799367.有任何疑问可与笔者或加群交流 CentOS7的网卡名称太长,这不符合我们的使用习惯, ...

  8. CentOS 7命令行修改网卡名称

    在CentOS学习中,配置多个网卡,配置独立的IP地址,为网卡设置新的名称等,已经是必备技能,经小编亲测,以下方法能修改系统的网卡名称,操作步骤和截图一并和小伙伴们分享, 希望对大家的学习和使用有所帮 ...

  9. 如何在RHEL7或CentOS 7系统下修改网卡名称(亲测有效~!)

    亲测有效的更改RHEL7或CentOS 7的网卡名称的方法, 按照以下4步来操作就可以实现! Step 1 :网卡配置文件名称重命名为eth0[root@localhost ~]# ifconfige ...

随机推荐

  1. Jupyter notebook远程访问linux服务器

    [转]https://blog.csdn.net/akon_wang_hkbu/article/details/78973366

  2. Spring+Velocity+Mybatis入门

    转自:https://blog.csdn.net/duqi_2009/article/details/47752169 一.开发工具 开发过程中使用的操作系统是OS X,关于软件安装的问题请大家移步高 ...

  3. POJ 3461 Oulipo 【KMP统计子串数】

    传送门:http://poj.org/problem?id=3461 Oulipo Time Limit: 1000MS   Memory Limit: 65536K Total Submission ...

  4. 二、IntelliJ IDEA 安装目录的核心文件讲解

    首先,咱们回顾一下前两篇关于 IntelliJ IDEA 的博文的内容: 在“在 Windows 系统下安装 IntelliJ IDEA 的方法”中,咱们知道了在 Windows 系统下如何下载并安装 ...

  5. ajax请求相关问题

    Ajax中async:false/true的作用: async. 默认是 true,即为异步方式,$.ajax执行后,会继续执行ajax后面的脚本,直到服务器端返回数据后,触发$.ajax里的succ ...

  6. vue2高仿饿了么app

    Github地址: https://github.com/ccyinghua/appEleme-project 一.构建项目所用: vue init webpack appEleme-project ...

  7. oracle client安装与配置

    (一)安装Oracle client 环境:windows7 64-bit.oracle client 64-bit (1)解压client安装包 (2)双击setup.exe,选择管理员,一直nex ...

  8. TinyMCE(富文本编辑器)在Asp.Net中的使用方法

    TinyMCE(富文本编辑器)在Asp.Net中的使用方法   转至:http://www.cnblogs.com/freeliver54/archive/2013/02/28/2936506.htm ...

  9. 【TOJ 1449】Area of Circles II(求不同位置的两圆面积之和)

    描述 There are two circles on the plane. Now you must to calculate the area which they cover the plane ...

  10. MySql基本数据类型及约束

    1. 常用的数据类型(data_type) 字符串类型 CHAR(n) : 固定长度 VARCHAR(n) : 可变长度 NCHAR(n) : 使用utf8存储,固定长度 NVARCHAR(n) : ...