Linux NIC changed from eth0 to eth1, how to fix it (MAC address is inconsistent)

Source: Internet
Author: User

Linux NIC changed from eth0 to eth1, how to fix

With WMware installed Linux, after successful installation, the network card used is eth0, there is no eth1. But after a period of time, do not know why eth0 can not be used, the system has automatically generated a ETH1 network card, which can be used to see the ifconfig command.

[User@localhost ~]$ Ifconfig

eth1 Link encap:ethernet HWaddr 00:0c:29:a9:22:9d

inet addr:192.168.1.108 bcast:192.168.1.255 mask:255.255.255.0

Inet6 ADDR:FE80::20C:29FF:FEA9:229D/64 Scope:link

Up broadcast RUNNING multicast mtu:1500 metric:1

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

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

collisions:0 txqueuelen:1000

RX bytes:67356 (65.7 KiB) TX bytes:26612 (25.9 KiB)

Interrupt:19 Base address:0x2000

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:1788 errors:0 dropped:0 overruns:0 frame:0

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

collisions:0 txqueuelen:0

RX bytes:89560 (87.4 KiB) TX bytes:89560 (87.4 KiB)

When you use the Service network Restart Directive to restart the Network service, you will see a hint that the eth0 NIC does not exist.

After Baidu, learned some information, hereby recorded here, in case of forgetting.

Why would eth0 become eth1?

Many Linux distribution use Udev to dynamically manage device files and name them based on the device's information. Udev identifies the network card during system boot and records the MAC address and network card name in Udev's rules script. For a new virtual machine, VMware will automatically generate a MAC address for the virtual machine's network card, when you clone or reload the virtual machine software, because you are using the previous system virtual hard disk information, and the system has eth0 information, for this new network card, Udev will automatically name it eth1 (the cumulative principle), so after your system starts, you use Ifconfig to see the NIC named Eth1.

How to restore to eth0?

In Fedora, the script for Udev Records network rules is:/etc/udev/rules.d/70-persistent-net.rules

[User@localhost ~]$ Vi/etc/udev/rules.d/70-persistent-net.rules

# This file is 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 0x1022:0x2000 (Pcnet32)

subsystem== "NET", action== "Add", drivers== "? *", attr{address}== "00:0c:29:5a:6c:73", attr{type}== "1", kernel== "eth*" , name= "Eth0"

subsystem== "NET", action== "Add", drivers== "? *", attr{address}== "00:0c:29:a9:22:9d", attr{type}== "1", kernel== "eth*" , name= "Eth1"

Open the file, you will find that there is eth0,eth1 two network card information, but in fact you can only find the ifconfig eth1 a network card information, because Eth0 does not exist at all.

Delete the information in the eth0, and change the device name in the eth1 information to eth0, restart the system, you see the network card is eth0, or delete all of the information restart System Udev will help you find new equipment.

There is also a startup script file/etc/sysconfig/network-scripts/ifcfg-eth0, the MAC address in the file is the physical address of the original eth0 NIC, and the virtual machine assigns a new physical address to eth1. Therefore, the information in the startup script does not match the actual information, the MAC address information modified to 70-persistent-net.rules in the Eth1 MAC address, restart the network again, fully restored to the status of the previous eth0 NIC.


Linux NIC changed from eth0 to eth1, how to fix it (MAC address is inconsistent)

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.