Ubuntu换网卡或mac地址改变时网络不可用时的解决办法

发表时间:2013-08-09 11:03 | 分类:Linux | 浏览:1,918 次

这篇文章主要解决ubuntu换网卡或者mac地址改变时网络不可用,网卡启动不起来的问题,特别是在我们使用虚拟机的时候。

在ubuntu系统中,网络接口的名称被记录在/etc/udev/rules.d/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 0x168c:/sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0 (ath9k)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="2c:d0:5a:54:3e:8
0", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"

# PCI device 0x1969:/sys/devices/pci0000:00/0000:00:1c.3/0000:04:00.0 (alx)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="3c:97:0e:f9:ab:c
6", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

在Ubuntu 中,通常有线网卡为eth0,无线网卡则为wlan0,后续增加的以此类推。上面记录了两张网卡信息,有线网卡的信息在最后叫“eth0”的记录里面。如果我们换了网卡或者mac地址,eth0肯定就启动不起来了。所以解决办法很简答,删除这个记录或者直接删除/etc/udev/rules.d/70-persistent-net.rules这个文件,然后重启一下系统就可以了。


root@test:~#  rm f /etc/udev/rules.d/70-persistent-net.rules

root@test:~# reboot

本文标签:

本文链接:https://www.sijitao.net/1383.html

欢迎您在本博客中留下评论,如需转载原创文章请注明出处,谢谢!

一键脚本 博客历程 留言联系 文章归档 网站地图 谷歌地图
Copyright © 2010-2024 章郎虫博客 All Rights Reserved.