Installation and configuration of Ethernet card under Linux operating system

  

The Linux operating system is favored by more and more people with its unique openness, stability and high efficiency. As IT industry giants announce their support for Linux, Linux is rapidly expanding its application market, especially the server market. On the standard, Linux is compatible with POSIX 1003.1, but it has a more reasonable kernel structure than the UNIX system that lives. Due to its openness, various widely used network protocols have been implemented in this system. The Linux system currently used generally refers to a distribution consisting of a Linux kernel, a shell (SHELL), and peripheral application software. The Linux distribution is the result of effectively binding Linux kernels, shells, installation tools, and application software to different companies or organizations. Therefore, there are many different types of advantages and disadvantages. But as a whole, these distributions have support for as many NICs as possible. This article only discusses the selection, installation, and configuration of NICs under the specific release version of RedHat. I hope that the same issues for other distributions can be used for reference.

Like UNIX, the NICs supported by Linux are mainly Ethernet cards. Ethernet cards such as 3COM, ACCTON, AT&T, IBM, CRYSTAL, D-LINK, etc., as long as the installation and configuration are correct, can get the effect you expect.

First, the working principle of Linux network card

In order to explain this problem more clearly, may wish to briefly analyze how Linux makes the network card work. In general, the Linux kernel has implemented the network layer and the upper layer of the OSI reference model. The implementation of the network layer relies on the efficient operation of the data link layer. The driver of the network card is the interface between the data link layer and the physical layer. The data is sent to the physical port by calling the driver's send routine, and the driver's receive routine is called to receive data from the physical port.

1. NIC Driver

Simply put, to use the NIC in your hand, the only thing you have to do is to get the driver for this NIC. The driver provides an interface to the operating system core and an interface to the physical layer.

The operating system interface of the driver is a routine for discovering network cards, detecting network card parameters, and sending and receiving data. When the driver starts to operate, the operating system first calls the detection routine to discover the network card installed in the system. If the network card supports plug and play, then the detection routine should automatically discover the various parameters of the network card; otherwise, you must set the parameters of the network card for the driver to use before the driver operates. When the core wants to send data, it calls the driver's send routine. The send routine writes the data to the correct space and then activates the physical send process.

The driver-oriented interface to the physical layer is the interrupt handling routine. When the network card receives the data, the transmission process ends, or an error is found, the network card generates an interrupt, and then the core calls the interrupt processing routine. The interrupt processing routine determines the cause of the interrupt and processes the response. For example, when the network card receives data and an interrupt occurs, the interrupt processing routine calls the receiving routine to receive.

2. Driver operating parameters

The operating parameters of the driver vary with the nature of the network card, including I/O port number, interrupt number, DMA channel, shared memory area, etc. The input and output port number is also referred to as the input and output base address, and is used when the network card operates in the port input/output mode. Port input and output mode requires full CPU intervention, but requires less hardware and storage space. The CPU exchanges data with the network card through the space specified by the port number. The interrupt number is the interrupt number of the network card, as long as it does not conflict with other devices. When the NIC uses the DMA method, it uses the DMA channel to transfer data in bulk without CPU intervention.

For a specific network card, if the network card supports full automatic detection, then one parameter is not specified, and the driver's detection routine will automatically set the required parameters. In general, you need to manually set a part of these parameters. If your network card uses port input and output mode, you need to set the port number and interrupt number. If your network card uses DMA mode, you need to set the DMA channel and interrupt number. If your network card uses the shared memory mode, then you have to set the address range of the shared memory area.

3. How to use the driver

With the driver of the network card, you can choose whether to add the driver to the Linux kernel or to process the driver into a separate module. A fascinating advantage of Linux systems is the ability to customize the core of the system. Adding functions that need to be called frequently to the core of the system can greatly improve the efficiency of the system. In this case, when the system starts, the system core automatically loads the driver of the network card. Driver parameters can be specified via the LILO command parameters. After the system boots, the driver permanently resides on the core and cannot be unloaded in the usual way. As for the core of the customized system, it is obtained by recompilation; how to compile the core will be described later.

If you compile the driver into a loadable module, you can use the commands provided by the system to load it at any time after the system is started. The advantage of loading at any time is to reduce memory overhead and ease management, but at the same time sacrifice the efficiency of a little network transmission. Driver parameters are entered directly on the command line or specified through a configuration file.

Second, the preparation of the network card before installation


Before installing the network card, be sure to check whether the following conditions are met:

1. Hardware aspects

●Ethernet card

●Network cable and connector, such as 10base-T is generally 8-core twisted pair with RJ-45 interface

2.Software

●Linux operating system

● NIC driver (target code or source code)

●* NIC configuration program

●* software development tools such as GNU toolkit (including compiler gcc, make, etc.)

3. System configuration information

● Available port address

● Available interrupt number

None Marked with an asterisk is a necessary condition, and an asterisk is a condition that is required depending on the situation. The details are further explained below.

Third, the installation and configuration of the network card

Step 1: Configure the working parameters of the Ethernet card

Configure the network card is to configure the working parameters of the network card, such as port address, interrupt number Wait. The default parameters of the network card are generally stored in the EEPROM inside the network card, which is set before the network card is shipped from the factory. The default parameters are feasible in most cases, but if these parameters conflict with your system and the network card does not support software dynamic settings, then you should use the network card settings program. Not all NICs go through this step because some NICs support the operating parameters of the NIC through the driver software and its input parameters. This can be determined by consulting the NIC's instruction manual.

The setting procedure of the network card is different from the driver. The setting program is only used to modify the settings in the NIC EEPROM. The NIC program itself may run under other operating systems, such as WINDOWS95/98, OS/2, DOS, etc. If it is a non-Linux platform, then you should first install the network card in the system suitable for the setup program, and set the network card parameters according to the setup program description. Then install the NIC under Linux.

Step 2: Install Linux System

If you are not installing the Linux system to install the Ethernet card, you can first try to install the network card while installing Linux. The prerequisite for this success is that your Linux distribution contains drivers for the NICs that will be installed.

Run the Linux installer and follow the prompts. Don't forget to install the core network part. When you go to LAN configuration, the installer lists all the types of network cards it supports. See if your network card is on the list. With the continuous upgrade of Linux distributions, RedHat 6.0 has covered the common network card types. If you are lucky enough that your network card is in it, then many of the steps discussed below can be ignored, and the installer will automatically complete the installation and driver of the network card. But if you don't find the type of NIC that works for you, don't worry, move on to the next step.

Step 3: Manually install the network card

Installing the network card is the driver for installing the network card. The NIC must have a driver to work, and the more mature the driver, the better. Drivers are typically provided by the manufacturer or supplier of the network card. Since Linux is a new operating system that started shortly, NIC manufacturers do not necessarily provide drivers for Linux environments. At this time, you have to find a way from other sources, such as the Internet to provide a hardware driver to find a website, you can also post a help message on the newsgroup. In short, the next step is to get the driver for the NIC.

There are two types of NIC drivers. One is the binary code that can be used directly; the other is the source code of the driver. Binary code is generally a pre-compiled loadable module. The source code can be compiled into a loadable module or compiled into a part of the system core. How to compile the source code into a loadable module is beyond the scope of this article. You can refer to the driver's manual for details.

1. Use of Loadable Modules

The system provides a set of commands for loading driver modules into memory for execution. These commands include modprobe, insmod, ismod, rmmod. Modprobe is similar to the insmod command, but in a different way.

The modprobe command uses the configuration file /erc/config.modules to load executable modules. To load the Ethernet card driver with the modprobe command, you can add it to the config.modules file:

alias eth0 drivermodule (drivermodule is the name of the driver module)

This line of configuration information puts the ether The device name of the NIC is associated with the driver module. The modprobe command automatically loads the module named drivermodule.o stored in the /lib/library/xxxx/net directory based on this information. So in order for the modprobe command to find the driver module, the module must be placed in the /lib/library/xxxx/net directory.

So how do you specify the parameters of the driver? Or use the conf.modules file. The method is to add the following information after the above configuration information:

options drivermodule parml=valuel,parm2=value2,...

where parm1 is the parameter name acceptable to the driver, and valuel is The parameter value; and so on.

For example, options cs89x0 io=0x200 irq=0xA media=aui

● The insmod command loads the driver module directly into memory via command line arguments and can specify driver parameters in the command. For example:

insmod drivermodule.o parml=valuel,parm2=value2,...

Driver parameters can be used in the above two commands depending on the specific network card and its driver. Read the instructions for the network card and driver carefully. Some NIC drivers can use these parameters to override the parameters stored in the EEPROM of the NIC itself. Some must use the parameters in the EEPROM. Some because the driver does not automatically detect the parameters used by the network card, so the parameters in the EEPROM used by the network card must be passed to the driver.

Copyright © Windows knowledge All Rights Reserved