ubuntu16.04,如何修改网卡名称为eth0,wlan0

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
头像
Archer123
帖子: 146
注册时间: 2008-05-18 10:16

ubuntu16.04,如何修改网卡名称为eth0,wlan0

#1

帖子 Archer123 » 2016-05-09 14:37

可以了,这样操作是对的.我总结一下把
问题就是 当你重新或全新安装uubntu16.04后,(如果你当初配置过静态局域网IP 或其他相关 升级系统到16.04的话不会有此问题).
你会发现16.04 已经通过udev和systemd 管理的网卡命名.
你ifconfig 下会发现eth0 变成了enp4s0f1 wlan0变成了wlp3s0.

然后我们已经习惯了eth0 和waln0了,那我们在ubuntu16.04 如何正确的配置回网卡名称为eth0和wlan0呢?
参考资料如下:
http://www.07net01.com/2015/10/938129.html
http://unix.stackexchange.com/questions ... istent-net

实际这样在16.04如下操作就对了
1 sudo apt-get install biosdevname
2 sudo gedit /etc/default/grub
把相关行 改成
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
3 保存后,执行 sudo grub-mkconfig -o /boot/grub/grub.cfg
4 重启系统

这样重启系统后,你就会发现ifconfig 后你的网卡名又自动变回 eth0 和wlan0了.
但是这时候,在/etc/udev/rules.d/ 还是只有一个默认的60-vboxdrv.rules 并没有类似 70-persistent-net.rules 或 80-net-setup-link.rules 这样的文件生成.

重启后如果没生效,那你在第3步骤 再试试执行 sudo update-grub 或者先sudo update-grub 再grub-mkconfig -o /boot/grub/grub.cfg 再重启系统ifconfig查看下试试.
因为我是参考着来的,最后也不确定 是哪行命令有效.
头像
Archer123
帖子: 146
注册时间: 2008-05-18 10:16

Re: ubuntu16.04,如何修改网卡名称为eth0,wlan0

#2

帖子 Archer123 » 2016-05-09 14:53

我想了想 好像真正起作用的是这行 net.ifnames=0 .

因为我第一此失败 只是改成了 GRUB_CMDLINE_LINUX="biosdevname=0" 这样修改 重启后并没有效果.

想确定的人可以试试,到底是 GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0" 还是 GRUB_CMDLINE_LINUX="net.ifnames=0" 有效.
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: ubuntu16.04,如何修改网卡名称为eth0,wlan0

#3

帖子 poloshiao » 2016-05-09 16:02

參考

1. http://askubuntu.com/questions/689070/n ... ev-changes
Network interface name changes after update to 15.10 - udev changes

2. https://www.freedesktop.org/wiki/Softwa ... faceNames/
I don't like this, how do I disable this?
You basically have four options: 有四個選項
You disable the assignment of fixed names, so that the unpredictable kernel names are used again. For this, simply mask udev's rule file for the default policy: ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
You create your own manual naming scheme, for example by naming your interfaces "internet0", "dmz0" or "lan0". For that create your own .link files in /etc/systemd/network/, that choose an explicit name or a better naming scheme for one, some, or all of your interfaces. See systemd.link(5) for more information.
You pass the net.ifnames=0 on the kernel command line
lsz7575
帖子: 1
注册时间: 2016-07-04 18:52
系统: ubunt

Re: ubuntu16.04,如何修改网卡名称为eth0,wlan0

#4

帖子 lsz7575 » 2016-07-04 18:57

感谢分享.正常使用........插上显示器发现,,载入到bios界面没启动..我靠..
回复