Royc30ne

Royc30ne

机器学习 | 联邦学习 | VPS | 摄影 | 日常

[Linux Guide] Viewing Network Card Configuration and Switching Network Card Operation Mode

Introduction

A few days ago, when testing the speed of the internal network on zimaboard, I found that the network speed was stuck at 100Mbps. After multiple debugging attempts, I found that it was because the network card was configured as 100M full duplex for some unknown reason. So, I recorded how I configured the network card in Linux. In the Linux operating system, the network card is one of the key components that connects the computer and the network. The speed and working mode of the network card directly affect the speed and stability of the network connection. This article will introduce how to view the network card configuration information in Linux and how to switch the working mode of the network card.

Some basic knowledge

Working principle of the network card

The network card is the interface device between the computer and the network. It is responsible for converting computer data into network data and converting network data into data that the computer can process. The working principle of the network card is to connect the network cable to the switch, and transfer data packets from one network node to another.

Network card speed

The speed of the network card refers to the amount of data that the network card can transfer per second, usually expressed in Mbps (megabits per second). In network communication, the faster the speed of the network card, the faster the data transmission speed. Gigabit Ethernet is the commonly used high-speed network interface, with a speed of 1000Mbps.

Full duplex and half duplex

Full duplex means that both parties can send and receive data at the same time. Half duplex means that both parties cannot send and receive data at the same time, they can only send or receive first. Full duplex communication is more efficient and stable than half duplex communication.

View network card configuration information

To view the network card configuration information in the Linux system, you can use the ifconfig command. This command can list all the network interface devices in the system and their configuration information. Enter the following command in the terminal:

ifconfig

Output example:
...

Switch network card working mode

In the Linux system, you can use the ethtool command to configure the working mode of the network card. ethtool is a tool for configuring network interface devices. It can view and modify the driver and hardware settings of network interface devices.

Step 1: Install ethtool

If the ethtool tool is not installed in the system, you can install it with the following command:

#centos
sudo yum install ethtool

#debian,ubuntu
sudo apt install ethtool

Step 2: View network card working mode

To view the current working mode of the network card, you can use the following command:

ethtool
#e.g. ethtool eth0

Where eth0 is the name of the network card to be viewed. This command will output the configuration information of the network card, including the current working mode.

Step 3: Modify network card working mode

To modify the working mode of the network card, you can use the following command:

ethtool -s eth0 speed 1000 duplex full

Where eth0 is the name of the network card to be modified, speed is the speed of the network card, and duplex is the working mode of the network card. Here, the speed of the network card is set to 1000Mbps, and the working mode is set to full duplex mode. After completion, you can use the ethtool command to view the configuration information of the network card again to confirm that the settings have taken effect.

Supplement: Detailed usage of ethtool

View network card information

To view the information of a network interface device, you can use the following command:

ethtool eth0

Where eth0 is the name of the network interface device to be viewed. This command will output detailed information of the network interface device, including driver information, speed, working mode, etc.

Modify network card speed

To modify the speed of a network interface device, you can use the following command:

ethtool -s eth0 speed 1000

Where eth0 is the name of the network interface device to be modified, and speed is the speed value to be set. Here, the speed of the network card is set to 1000Mbps.

Modify network card working mode

To modify the working mode of a network interface device, you can use the following command:

ethtool -s eth0 duplex full

Where eth0 is the name of the network interface device to be modified, and duplex is the working mode to be set. Here, the working mode of the network card is set to full duplex mode.

Enable or disable auto-negotiation

Auto-negotiation is a technology that automatically negotiates the speed and duplex mode of a device. To enable or disable auto-negotiation, you can use the following command:

ethtool -s eth0 autoneg on/off

Where eth0 is the name of the network interface device to be modified, and autoneg is the auto-negotiation status to be set. Here, auto-negotiation is set to the on state.

View network card statistics

To view the statistics of a network interface device, you can use the following command:

ethtool -S eth0

Where eth0 is the name of the network interface device to be viewed. This command will output the statistics of the network interface device, including the number of received and transmitted packets, error counts, etc.

Summary

This article introduces how to view the network card configuration information in Linux and how to switch the working mode of the network card. By using the ethtool command, it is easy to switch the working mode of the network card.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.