linux 改网卡名 dell,Ubuntu下更改eth0网卡名称为eth1

Ubuntu下更改eth0网卡名称为eth1

862375_19005849.shtml

您查看的文章来源于http://www.oklinux.cn

这个方法用于解决Ubuntu下更换网卡后,新网卡变更为eth1,并且源网卡的名称eth0,无法给新网卡用的情况。也可以用于为网卡更名。

网卡MAC地址改变之后,在Linux中找到网卡,新的网卡会被识别为eth1或者更为靠后的网卡写入到/etc/udev/rules.d/70-persistent-net.rules这个文件中,修改/etc/udev/rules.d/70-persistent-net.rules这个文件,将eth0的MAC地址修改为改变后的地址就可以。

编辑

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

root@shangyuan-laptop:/etc/udev/rules.d# more 70-persistent-net.rules

# This file maintains persistent names for network interfaces.

# See udev(7) for syntax.

#

# Entries are automatically added by the 75-persistent-net-generator.rules

# file; however you are also free to add your own entries.

# PCI device 0x14e4:0x1713 (tg3)

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1e:ec:0f:79:f

6", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x4222 (iwl3945)

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1f:3c:48:70:b

1", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"

将其中的eth0,改为eth1,保存后重启系统即可。

这个方法用于解决Ubuntu下更换网卡后,新网卡变更为eth1,并且源网卡的名称eth0,无法给新网卡用的情况。也可以用于为网卡更名。

网卡MAC地址改变之后,在Linux中找到网卡,新的网卡会被识别为eth1或者更为靠后的网卡写入到/etc/udev/rules.d/70-persistent-net.rules这个文件中,修改/etc/udev/rules.d/70-persistent-net.rules这个文件,将eth0的MAC地址修改为改变后的地址就可以。这个方法用于解决Ubuntu下更换网卡后,新网卡变更为eth1,并且源网卡的名称eth0,无法给新网卡用的情况。也可以用于为网卡更名。

网卡MAC地址改变之后,在Linux中找到网卡,新的网卡会被识别为eth1或者更为靠后的网卡写入到/etc/udev/rules.d/70-persistent-net.rules这个文件中,修改/etc/udev/rules.d/70-persistent-net.rules这个文件,将eth0的MAC地址修改为改变后的地址就可以。

编辑

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

root@shangyuan-laptop:/etc/udev/rules.d# more 70-persistent-net.rules

# This file maintains persistent names for network interfaces.

# See udev(7) for syntax.

#

# Entries are automatically added by the 75-persistent-net-generator.rules

# file; however you are also free to add your own entries.

# PCI device 0x14e4:0x1713 (tg3)

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1e:ec:0f:79:f

6", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x4222 (iwl3945)

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1f:3c:48:70:b

1", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"

将其中的eth0,改为eth1,保存后重启系统即可。

为了高效的解决在应用此方案时遇到的问题,欢迎大家使用eden附带的文章评论功能提出使用问题或更好的解决方案。您的问题将得到及时的答复,谢谢。

更换主板后,Ubuntu无法访问网络

来源: ChinaUnix博客  日期: 2009.03.18 17:55 (共有0条评论) 我要评论

Dell的Optilex745最近出了些问题, 报告给DELL后,那边今天派人来了,解决方案倒是简单, 直接更换了主板.

换完后,启动了一下,没去连接网络, 所以就没发现问题. 等到后来弄到机房启动机器, 发现机器无法访问网络了.

用ifconfig一看,有两个网络设备:lo 和 eth1,

再查看一下/etc/network/interfaces,发现条目是lo和eth0,

执行ifup --force eth0, 提示设备不存在

也就是说, 主板没更换前, 网卡被命名为eth0,而现在被命名为eth1,eth0已经不复存在了.

解决方法有两种:

1 更改/etc/network/interfaces,将eth1都改为eth0, 我先这样作了一下,而后/etc/init.d/networking restart重启网络服务, 结果就可以访问网络了.

我发现/etc底下还有某些配置文件使用eth0, 但是也不多. 这种情况好办, 将这些文件用sed作一次替换就可以了, 使用这些配置的软件就不会有问题了.

只是,google一下,发现其实有些软件默认使用的就是eth0,eth1对他们来说无效.

2 所以,最好的方式,还是让该网卡被命名为eth0, 看到有些机器上有ifrename,试了一下,发现不存在. 于是,就只有修改配置文件了, 该配置文件是/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.

# PCI device 0x14e4:0x167a (tg3)

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:19:b9:43:c7:86", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x14e4:0x167a (tg3)

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1a:a0:bd:14:05", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

修改一下该文件,将eth0的那行注释掉,而后将eth1改为eth0

而后再重启网络服务, 这样该网卡就变为了eth0,既不需修改其他配置文件,又不会对以后装软件造成影响了.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值