search
HomeComputer TutorialsComputer KnowledgeBinding method of linux network card identification sequence

Binding method of linux network card identification sequence

Mar 08, 2024 pm 07:07 PM
network cardDriver InstallationNIC drivernameeth

When using a Linux system, network card drift may occur after installing specific network card drivers or related programs.

Binding method of linux network card identification sequence

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!

Statement
This article is reproduced at:每日运维. If there is any infringement, please contact admin@php.cn delete
Top 5 Solutions to Valorant Connection Error Windows 10/11 - MiniToolTop 5 Solutions to Valorant Connection Error Windows 10/11 - MiniToolMay 13, 2025 am 12:54 AM

Valorant has encountered a connection error when gaming? What will you do when that happens on PC? Take it easy. Every problem has a fix. Valorant is also no exception. In this article on php.cn Website, I bet you must find satisfying solutions.

How to Remove PUA:Win32/FlashHelper on Windows 10/11?How to Remove PUA:Win32/FlashHelper on Windows 10/11?May 13, 2025 am 12:53 AM

What to do if you see a message saying that PUA:Win32/FlashHelper was located on your PC? Do you know what it is? This is a potentially unwanted software and might threaten your data and system. Once your computer is infected by it, follow this guide

Fix Some Common Chrome Connection Errors while Browsing a Website - MiniToolFix Some Common Chrome Connection Errors while Browsing a Website - MiniToolMay 13, 2025 am 12:51 AM

In this post, php.cn Software lists some common Chrome connection errors you might encounter when browsing a webpage and introduces some easy methods to solve these issues. You can find the error you encounter and use the corresponding solutions to h

What Are Cookies on the Internet? Are Cookies Bad? - MiniToolWhat Are Cookies on the Internet? Are Cookies Bad? - MiniToolMay 13, 2025 am 12:50 AM

Cookies may not sound new to you because you encounter them almost every day when you browse web pages. But do you know what exactly cookies are? This guide on php.cn Website will show you detailed information about them.

How to Print Photos/Documents from iPhone to HP Printer in 3 Ways - MiniToolHow to Print Photos/Documents from iPhone to HP Printer in 3 Ways - MiniToolMay 13, 2025 am 12:49 AM

If you want to print photos from iPhone, what should you do? The operation is not difficult as long as you follow three ways in this post. php.cn will show you a detailed guide on how to print from iPhone to HP printer. Now, let’s go to see them.

How To Make The Xbox Download Faster: Tips & Methods - MiniToolHow To Make The Xbox Download Faster: Tips & Methods - MiniToolMay 13, 2025 am 12:48 AM

Xbox is very popular among people since it offers a large variety of games. Users can download the games they like and then start to play them directly. However, one of the common problems related to Xbox is the slow download speed. Users want to fin

Can't Turn on Developer Mode in Windows 11? Fix It via 4 Ways! - MiniToolCan't Turn on Developer Mode in Windows 11? Fix It via 4 Ways! - MiniToolMay 13, 2025 am 12:47 AM

If you are a developer, you may enable Developer Mode in Settings to do some tests. However, if you can’t turn on Developer Mode in Windows 11, what should you do? Take it easy and you can find some effective ways from this post written by php.cn Sol

Windows 10 KB5011543 Is Released with Search Highlights Feature - MiniToolWindows 10 KB5011543 Is Released with Search Highlights Feature - MiniToolMay 13, 2025 am 12:46 AM

Microsoft has released a new cumulative update for Windows 10 and it is Windows 10 KB5011543. This update contains some new features like Search highlights and some fixes. You can read this php.cn post to get some related information. Besides, you ca

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

mPDF

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),