How to solve the problem of NIC renaming when Linux Device Manager Udev upgrade

Source: Internet
Author: User

Fault Description

Recently finally updated the next Gentoo, reboot found that my eth0 network card failed to start:

* Bringing up interface eth0
* Error:interface eth0 does not exist
* Ensure that you have loaded the correct kernel module for your hardware
* ERROR:net.eth0 failed to start

And start some of my usual services, such as MongoDB, also error:

~ #/etc/init.d/mongodb Restart
* Bringing up interface eth0
* Error:interface eth0 does not exist
* Ensure that you have loaded the correct kernel module for your hardware
* ERROR:net.eth0 failed to start
* Error:cannot start MongoDB as Net.eth0 would not start

You also need to start the network card?

To view the kernel and DMESG:

Check the kernel module has been selected, and previously eth0 also have, and then look at DMESG

DMESG |grep Network
[74.261872] systemd-udevd[14259]: Renamed network interface wlan0 to WLP2S0
[74.391865] systemd-udevd[14259]: Renamed network interface eth0 to ENP0S4

The original was renamed.

Why?


From udev-197 will automatically assign better interface names, specific explanations please see [predictablenetworkinterfacenames] (http://www.freedesktop.org/wiki/Software/ Systemd/predictablenetworkinterfacenames),
Solution, there are three kinds

A temporary solution, restart or will fail

Ifrename-i enp0s4-n eth0 #修改网卡名字变成原来的eth0

Use a new name

Rm/etc/init.d/net.eth0 #删除不存在的引用

localhost ~ # rc-update Delete net.eth0 default #删除不存在的开机启动
* Service Net.eth0 removed from runlevel default
localhost ~ # rc-update Add net.enp0s4 default #使用新名字

Reset the rules of the udev, or use the original method

Ln-s/dev/null/etc/udev/rules.d/80-net-name-slot.rules

The second, and the third need to reboot

Why do I need to start the network card to start the application?

View the/etc/init.d/mongodb script, found because depend, the general initialization script structure is

#!/sbin/runscript

Depend () {
(Dependency information)
}

Start () {
(Commands necessary to start the service)
}

Stop () {
(Commands necessary to stop the service)
}

Restart () {
(Required to restart the service)
}

For example, MongoDB's dependence is

Depend () {
Need net #需要依赖net. X
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.