


Binding method of linux network card identification sequence
When using a Linux system, network card drift may occur after installing specific network card drivers or related programs.
Possible representations are:
After installing a certain network card driver, the order of the network cards may be reversed. For example, the network port connected by the network cable was eth0 before, but it may be changed to eth1 or other names after the driver is installed.
(2) The name of the network card changes. This situation is not a change from eth0 to eth1, but a very strange change. For example, eth0 cannot be found, and there is an additional network card named __tmp3183921382193__
This situation is indeed annoying. Because some people may need to use the ifconfig | grep eth command to obtain information for development work. If the network card name is confusing, there will definitely be errors in the program.
(3) The order of the optical port network card and the electrical port network card is out of order, or they overlap.
In short, our goal is to be able to specify the name of a certain network card as the physical device we want. Here’s how to do it:
The first step is to identify the network card information
To use a network card, you first need to know which name corresponds to which physical device. The method is as follows: pull a network cable from the switch and connect it to the network card one by one from top to bottom. Note that you can only connect one network card at a time. Then use the ethtool command to check whether the network cable is connected, such as
[root@bunian ~]# ethtool eth0 Settings for eth0: Supported ports: [ MII ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Supports auto-negotiation: Yes Advertised link modes:10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Advertised auto-negotiation: Yes Speed: 100Mb/s Duplex: Full Port: MII PHYAD: 2 Transceiver: external Auto-negotiation: on Supports Wake-on: g Wake-on: d Link detected: yes
I saw that the status of eth0 is connected to the network cable. If Linked detected:no, it means that the network cable is not connected.
In this way, distinguish the name of which device and mark it well.
Step 2: Obtain the MAC address of each network card
ifconfig -a can see all network devices. Get the MAC address of each device via ifconfig -a | grep HWaddr.
for example:
[root@bunian ~]# ifconfig-a | grep HWaddr eth0Link encap:EthernetHWaddr 00:30:48:7F:B5:CA eth1Link encap:EthernetHWaddr 00:30:48:7F:B5:CB eth2Link encap:EthernetHWaddr 00:04:23:A6:81:E0 eth3Link encap:EthernetHWaddr 00:04:23:A6:81:E1
Got the MAC address of each network card.
Step 3: Bind the MAC and network card name.
We all know that for RedHat systems, the configuration file of the network card is:
Stored in/etc/sysconfig/network-scripts/ifcfg-ethX, X=0, 1, 2. . .
for example:
[root@bunian]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 # nVidia Corporation MCP55 Ethernet DEVICE=eth0 ONBOOT=yes HWADDR=00:30:48:7f:b5:ca TYPE=Ethernet NETMASK=255.255.255.0 IPADDR=192.168.42.231 GATEWAY=192.168.42.1 BOOTPROTO=static #NAMESERVER=202.106.0.20
This file is the configuration file for initializing the network card. For example, if we want to specify the device name of the network card MAC address MAC1 as ethn, then modify the file
/etc/sysconfig/network-scripts/ifcfg-ethn
Add the configuration information of MAC address binding and name inside
DEVICE=ethn
HWADDR=MAC1 (for example 00:30:48:7f:b5:ca)
Other configuration information is not affected. After binding all network cards, reboot the system and it should be fine.
Another thing to note is the file that drives the corresponding relationship:
/etc/modprobe.conf
To modify in this file, make sure that a certain device uses the driver corresponding to it, such as:
cat /etc/modprobe.conf alias eth0 forcedeth alias eth1 forcedeth alias scsi_hostadapter aic79xx alias scsi_hostadapter1 sata_nv alias scsi_hostadapter2 usb-storage alias eth2 e1000 alias eth3 e1000
Explain that eth0 and eth1 use the forcedeth driver, and eth2 and eth3 use the e1000 driver.
Special case
After the server replaces the network card, the MAC address will change. At this time, after starting the Linux system, the original eth0 and eth1 are no longer the configuration files of the current network card, and a prompt will be displayed that device eth0 does not seem to be present.
Solution:
Just delete /etc/udev/rules.d/70-persistent-net.rules and then restart the machine, because this file saves the identification information of the network card at the bottom of the system, including the correspondence between ethX and MAC. Delete and Restart and let the operating system re-recognize the existing network card and then it will return to normal.
In addition, if the original eth0 and eth1 configuration files have HWADDR fields, they also need to be deleted.
The above is the detailed content of Binding method of linux network card identification sequence. For more information, please follow other related articles on the PHP Chinese website!

Do you have trouble downloading or sending attachments in Outlook 365? Sometimes, Outlook doesn’t show them for some unknown reason, so you are unable to see them. In this post on php.cn Website, we collect some use tips for attachments not showing.

When V Rising players try to join a server that is close to or already full, they may encounter the “V Rising connection timed out” issue. If you are one of them, you can refer to this post from php.cn to get solutions. Now, keep on your reading.

Windows supplies real-time protection via Windows Security. But this feature may prevent you from doing something it thinks are dangerous. In this situation, you may want to temporarily turn on real-time protection. This php.cn post will show you how

Microsoft has started working on next year’s Windows updates very early. Recent rumors state that the next update in 2024 might be Windows 11 24H2 rather than Windows 12. Everything is uncertain now. php.cn will now take you to see some related infor

The error 0x80030001 often happens when you are attempting to copy files. The error code will be accompanied by a message that tells “unable to perform requested operation”. If you are struggling with this error, you can read this article on php.cn W

On February 13, 2024, Microsoft released KB5034765 (OS builds 22621.3155 and 22631.3155) for Windows 11 22H2 and Windows 11 23H2. This security update brings you many new improvements and bug fixes. You can learn how to download and install Windows 1

Device Manager is widely used when you need to fix some computer issues. You can check the problematic devices and decide to uninstall or update device drivers. Besides, you can also set Power Management settings in Device Manager. However, you may f

When Backup and Restore (Windows Backup) fails to work, you can choose to reset it to default. How to restore Windows Backup to default in Windows 11/10? php.cn will guide you to easily do this thing in 2 ways and let’s go to see them.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version
Chinese version, very easy to use