Table of Contents
What is a network card?
Summary of basic knowledge about network cards in Linux
Home Common Problem What is a network card in linux

What is a network card in linux

Mar 02, 2023 pm 06:55 PM
linux network card

A network card is a piece of computer hardware used to allow computers to communicate on a computer network, allowing users to connect to each other via cables or wirelessly. In the Linux operating system, the traditional naming methods of network card devices are eth0, eth1, eth2, etc. Check the syntax of the network card model "lspci | grep -i ether", the syntax of the network card resource usage "sar -n DEV", and whether the network card supports Syntax for multi-queue "lspci -vvv | grep -i msi-x".

What is a network card in linux

The operating environment of this tutorial: CentOS7 system, Dell G3 computer.

What is a network card?


A network card is a piece of computer hardware designed to allow computers to communicate on a computer network. Since it has a MAC address, it falls between Layer 1 and Layer 2 of the OSI model. It allows users to connect to each other via cable or wirelessly.

Each network card has a unique 48-bit serial number called a MAC address, which is written in a ROM on the card. Every computer on the network must have a unique MAC address.

Summary of basic knowledge about network cards in Linux


##1. Overview of network cards## The traditional naming methods of network card devices in #Linux operating systems are eth0, eth1, eth2, etc., while CentOS7 provides different naming rules. The default is to assign based on firmware, topology, and location information. The advantage of this is that the naming is fully automatic and predictable, but the disadvantage is that it is more difficult to read than eth0 and wlan0, such as ens33.

2. The difference between Eth0 and ens

##eno1: represents the network card built into the host bios
  • Ens: Represents the PCI-E network card built into the motherboard bios
  • Enp2s0: PCI-E independent network card
  • Eth0: If none of the above is used, return to the default network card name
3. Naming rule strategy

Rule 1:

For onboard device naming, merge the index number provided by the firmware or BIOS. If the information from the firmware or BIOS is readable, name it, such as eno1. This kind of naming is more common. , otherwise rule 2 is used.

Rule 2:

Name the PCI-E hot plug port index number provided by the merged firmware or BIOS, such as ens1. If the information is readable, use it, otherwise use it. Rule 3.

Rule 3:

Name the physical location of the merged hardware interface, such as enp2s0. Name it if it is available. If it fails, go directly to solution 5.

Rule 4:

Name the MAC address of the merged interface, such as enx78e7d1ea46da, which is not used by default unless the user chooses to use this scheme.

Rule 5:

Use traditional solutions. If all else fails, use a style like eth0.

4. The meaning of the network card name characters

1. The meaning of the first 2 characters

en Ethernet Ethernet

wl Wireless LAN WLAN

ww Wireless WAN WWAN

2. The third character is selected according to the device type

##o

    x                                                                                     MAC address
  • ps           PCI geographical location
  • p USB port number chain
  • ##5. Modify the network card name style to ethx

  • If you are not used to it Using the new naming rules, you can restore the traditional naming method, edit the grub file, add two variables, and then use grub2-mkconfig to regenerate the grub configuration file.

  • 1. Edit the grub configuration file

vim /etc/sysconfig/grub   # 其实是/etc/default/grub的软连接
Copy after login
# Add 2 parameters to the GRUB_CMDLINE_LINUX variable. The specific content is as follows (bold):
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=cl/root rd.lvm.lv=cl/swap net.ifnames=0 biosdevname=0 rhgb quiet"
Copy after login
2. Regenerate grub configuration file

grub2-mkconfig -o /boot/grub2/grub.cfg
Copy after login

然后重新启动 Linux 操作系统,通过 ip addr 可以看到网卡名称已经变为 eth0 。

3、修改网卡配置文件

原来网卡配置文件名称为 ifcfg-ens33,这里需要修改为 ethx 的格式,并适当调整网卡配置文件。

mv /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-eth0
# 修改ifcfg-eth0文件如下内容(其它内容不变)
NAME=eth0
DEVICE=eth0
Copy after login
[root@localhost ~]# systemctl restart network.service    # 重启网络服务
Copy after login

注意:ifcfg-ens33 文件最好删除掉,否则重启 network 服务时候会报错

TYPE=Ethernet                # 网卡类型:为以太网
PROXY_METHOD=none            # 代理方式:关闭状态
BROWSER_ONLY=no                # 只是浏览器:否
BOOTPROTO=dhcp                # 网卡的引导协议:DHCP[中文名称: 动态主机配置协议]
DEFROUTE=yes                # 默认路由:是, 不明白的可以百度关键词 `默认路由`
IPV4_FAILURE_FATAL=no        # 是不开启IPV4致命错误检测:否
IPV6INIT=yes                # IPV6是否自动初始化: 是[不会有任何影响, 现在还没用到IPV6]
IPV6_AUTOCONF=yes            # IPV6是否自动配置:是[不会有任何影响, 现在还没用到IPV6]
IPV6_DEFROUTE=yes            # IPV6是否可以为默认路由:是[不会有任何影响, 现在还没用到IPV6]
IPV6_FAILURE_FATAL=no        # 是不开启IPV6致命错误检测:否
IPV6_ADDR_GEN_MODE=stable-privacy            # IPV6地址生成模型:stable-privacy [这只一种生成IPV6的策略]
NAME=ens33                    # 网卡物理设备名称
UUID=f47bde51-fa78-4f79-b68f-d5dd90cfc698    # 通用唯一识别码, 每一个网卡都会有, 不能重复, 否两台linux只有一台网卡可用
DEVICE=ens33                    # 网卡设备名称, 必须和 `NAME` 值一样
ONBOOT=no                        # 是否开机启动, 要想网卡开机就启动或通过 `systemctl restart network`控制网卡,必须设置为 `yes`
Copy after login

/etc/sysconfig/network # 包括主机基本网络信息,用于系统启动 /etc/sysconfig/network-script/ # 此目录下是系统启动最初始化网络的信息 /etc/sysconfig/network-script/ifcfg-em1 # 网络配置信息,每个人的配置名字不一样通过命令查看 /etc/xinetd.conf 定义了由超级进程XINETD启动的网络服务 /etc/protocols # 设定了主机使用的协议以及各个协议的协议号 /etc/services # 设定了主机的不同端口的网络服务

六、查看虚拟化有没有开启

Ctrl+alt+delete

What is a network card in linux

七、基础命令

查看网卡型号: lspci | grep -i ether

查看网卡资源使用情况: sar -n DEV(重点看网络带宽);

查看网卡eth0的队列:/sys/class/net/eth0/queues

查看网卡是否支持多队列: lspci -vvv | grep -i msi-x

  如下图所示,查看Ethernet controller的条目内容,如果有MSI-X && Enable+ && TabSize > 1,则该网卡是多队列网卡,TabSize表示该网卡支持的队列数。

What is a network card in linux

相关推荐:《Linux视频教程

The above is the detailed content of What is a network card in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

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 Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use docker desktop How to use docker desktop Apr 15, 2025 am 11:45 AM

How to use Docker Desktop? Docker Desktop is a tool for running Docker containers on local machines. The steps to use include: 1. Install Docker Desktop; 2. Start Docker Desktop; 3. Create Docker image (using Dockerfile); 4. Build Docker image (using docker build); 5. Run Docker container (using docker run).

Difference between centos and ubuntu Difference between centos and ubuntu Apr 14, 2025 pm 09:09 PM

The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

What to do if the docker image fails What to do if the docker image fails Apr 15, 2025 am 11:21 AM

Troubleshooting steps for failed Docker image build: Check Dockerfile syntax and dependency version. Check if the build context contains the required source code and dependencies. View the build log for error details. Use the --target option to build a hierarchical phase to identify failure points. Make sure to use the latest version of Docker engine. Build the image with --t [image-name]:debug mode to debug the problem. Check disk space and make sure it is sufficient. Disable SELinux to prevent interference with the build process. Ask community platforms for help, provide Dockerfiles and build log descriptions for more specific suggestions.

How to view the docker process How to view the docker process Apr 15, 2025 am 11:48 AM

Docker process viewing method: 1. Docker CLI command: docker ps; 2. Systemd CLI command: systemctl status docker; 3. Docker Compose CLI command: docker-compose ps; 4. Process Explorer (Windows); 5. /proc directory (Linux).

What computer configuration is required for vscode What computer configuration is required for vscode Apr 15, 2025 pm 09:48 PM

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

Detailed explanation of docker principle Detailed explanation of docker principle Apr 14, 2025 pm 11:57 PM

Docker uses Linux kernel features to provide an efficient and isolated application running environment. Its working principle is as follows: 1. The mirror is used as a read-only template, which contains everything you need to run the application; 2. The Union File System (UnionFS) stacks multiple file systems, only storing the differences, saving space and speeding up; 3. The daemon manages the mirrors and containers, and the client uses them for interaction; 4. Namespaces and cgroups implement container isolation and resource limitations; 5. Multiple network modes support container interconnection. Only by understanding these core concepts can you better utilize Docker.

vscode cannot install extension vscode cannot install extension Apr 15, 2025 pm 07:18 PM

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

What is vscode What is vscode for? What is vscode What is vscode for? Apr 15, 2025 pm 06:45 PM

VS Code is the full name Visual Studio Code, which is a free and open source cross-platform code editor and development environment developed by Microsoft. It supports a wide range of programming languages ​​and provides syntax highlighting, code automatic completion, code snippets and smart prompts to improve development efficiency. Through a rich extension ecosystem, users can add extensions to specific needs and languages, such as debuggers, code formatting tools, and Git integrations. VS Code also includes an intuitive debugger that helps quickly find and resolve bugs in your code.