Библиотека сайта rus-linux.net
Linux System Administrator's Survival Guide lsg29.htm
Configuring Hardware and the Kernel for Networking
To network your Linux machine, you need to connect it to others. The last chapter showed you the basics of networking, as well as the different network topologies you can use for local area networks. The next step is to configure the hardware and Linux kernel for networking.
This chapter looks at the configuration settings you need to worry about on your Ethernet board (if you are using one) and the changes you need to make to the Linux kernel to invoke networking. Depending on the type of network and version of Linux you are using, the exact steps you need to take may differ slightly from the ones explained in this chapter, but the basic procedures are the same.
Configuring the Kernel
Practically all Linux versions have a number of default configurations built into the boot disks. When you selected a boot kernel, you could have chosen one with the Linux networking drivers already installed and configured. If you knew in advance that you were going to use networking and you chose one of these boot kernels, you have little work to do to complete the configuration.
You probably didn't choose a networking kernel when you first installed Linux because you didn't know you would need the drivers for networking or you didn't have the proper configurations available. Luckily, you don't have to go back and reinstall your entire system. Instead, you can link in the networking drivers and rebuild the kernel.(If you have not added any peripherals or saved any files you want to keep, however, reinstalling may be the fastest approach).
In order to configure network hardware (an Ethernet board, most likely), you need to install the board in your machine with known IRQ, DMA, and I/O address values. These addresses are usually set on the network board with DIP switches or jumpers or with software (which usually works only under DOS) in more recent boards. Choose values for the IRQ, DMA, and I/O address that do not conflict with other boards or devices in your system.
<NOTE>If you are unsure of what settings are available, watch the boot messages from Linux or use a utility under DOS like MSD or Norton Utilities to examine the hardware. If these methods don't help you determine available settings, make a good guess and use trial and error. Be warned that some network boards use the same DMA channel as popular SCSI controllers. If your network board is one of these and you don't change its DMA, the network board's instructions may overwrite data on your hard disk.<NOTE>
Many network boards have default values that work unless your system has a lot of additional cards installed. For example, many Ethernet boards default to values such as 15 for the IRQ and 300H for the I/O address. These values are not commonly used by sound cards, video capture boards, CD-ROM drivers, or SCSI cards. The IRQ setting is usually the easiest to select because a typical PC has only a few IRQ values preassigned, most of which are in the lower values from 1 to 7. The usual IRQ assignments for a basic AT-class machine (as opposed to the older XT class) are as follows:
|IRQ 3||COM2 (second serial port)|
|IRQ 4||COM1 (first serial port)|
|IRQ 5||LPT2 (second parallel port)|
|IRQ 6||Floppy controller|
|IRQ 7||LPT1 (first parallel port)|
Because most machines have two serial ports and at least one parallel port, these IRQ values are not available for you to use. IRQ 5 is often used by bus mouse controller boards if a second parallel port is not installed on your system. SCSI controller boards often default to IRQ 11, and 16-bit sound cards frequently use IRQ 10 as a default value. The most commonly available IRQ for a network board is IRQ 15, which is often the board's default value.
I/O addresses for network boards are usually restricted to a few settings, and you have to choose one that doesn't conflict with other devices. The most common setting is 300-31FH (300 to 31F hexadecimal), although this setting is often used by default settings on sound cards. The only commonly reserved I/O address on PC machines is 360-37FH, which is used by LPT2, the second parallel port. If you have a sound card installed at 300H, switch your network card to use an alternate address such as 320-33FH or 340-35FH. Both address blocks are usually available on a PC unless you have installed special hardware.
Many recent network boards allow you to select between 8-bit and 16-bit modes. The 16-bit mode is the fastest and most versatile and is therefore the default for most network boards. If you have only an 8-bit slot available for the network board, set your board to use 8-bits only (many boards detect this change automatically).
Many Linux kernel network drivers use an autoprobe routine that can detect the network board and its settings at boot time. The autoprobe routine uses a set of checks for network board addresses. If this routine succeeds in finding your network card, you see messages about the driver during the boot stage. You can redisplay the boot messages at any time with the dmesg command. Sometimes the autoprobe routine doesn't work or causes problems. In that case, be ready to enter the IRQ, DMA, and I/O address in the configuration files manually.(See the section "Forcing a Network Card Recognition" for more information.)
Understanding Network Drivers
The Linux kernel accesses network connections (whether an Ethernet board or a modem) through a device driver, which acts as an interface to the network service. Because the kernel can have many of these interfaces defined, including more than one per device driver, talking in terms of interfaces instead of device drivers helps to keep the concepts clear.
Each interface corresponds to a device driver file in the /dev directory. (The exception is SLIP device drivers, which are assigned dynamically and don't have a dedicated device driver file.) The Ethernet device drivers are usually called /dev/eth0, /dev/eth1, and so on. Each device driver can correspond to a different kind of device, so /dev/eth0 may be a device driver for an Intel Ethernet board, /dev/eth1 may be a device driver for a Novell Ethernet board, and so on. Alternatively, two or more boards can share the same device driver if they are the same kind of board. Usually, of course, a typical system has only one Ethernet board, and the device driver is designed for that board.
You may run into several different device driver names when using Linux. Knowing what the names mean helps you understand how they relate to the network protocols. The device driver names commonly encountered with Linux are as follows:
|dl||D-Link DE-600 pocket adapters (an Ethernet device connecting to the parallel port)|
|lo||A loopback driver (used primarily for testing and to maintain the network daemons when the network isn't active)|
|ipx||IPX interfaces (for Novell NetWare compatibility)|
|plip||PLIP interfaces (a parallel-port version of SLIP)|
All these device driver names are followed by a number, such as /dev/ppp0 /dev/ppp1, and so on to indicate whether it is the first, second, or higher device driver of that type. A few other device drivers are appearing for ISDN, X.25, and similar high-speed protocols, although they are not a part of most Linux distributions yet. You can usually obtain the latest device drivers from FTP or BBS sites.
Adding Network Support to the Kernel
If you need to add or configure network drivers because the kernel doesn't have them or the autoprobe routine didn't work, run the kernel building routines again. (If you are not familiar with the kernel build process, check the documentation that came with your Linux system.) Change to the directory used to store your Linux source files, which usually is /usr/src/Linux, and then start the kernel build process with the command
During the build routine (on all Linux kernels from version 1.0 and later), you are asked whether you want to include TCP/IP network support. Answer y to this question or the kernel will not be built with networking support.
Following the TCP/IP question, Linux's configuration routine asks more questions. The exact questions differ depending on the version of Linux you have. Usually, you are asked whether you want support for several different types of networking, including whether you want network board TCP/IP network support (if you use a network card, such as an Ethernet board, answer y), SLIP and CSLIP support (if you plan on using SLIP, answer y), PPP support (again, if you plan to use PPP, answer y), and PLIP. (PLIP is a parallel-port version of SLIP/PPP, which is seldom used. Answer n unless you are only connecting two machines. See "Setting Up PLIP.") For most installations, answer y to all prompts for support except PLIP to configure your network any way you want. You will probably use SLIP and PPP at some time.
Versions of Linux later than 1.1.14 add more specific questions about network support, such as whether you want IP forwarding and gatewaying (answer n for this question unless your system acts as a gateway to another network). Your Linux version may ask about PC/TCP compatibility modes. Answer this question with n; it refers to an old incompatibility with ftp Software's PC/TCP PC client software product.
Some versions of Linux ask whether you want to enable RARP (Reverse Address Resolution Protocol), which allows remote terminals to obtain their IP addresses when they boot. In most cases, answer n to this question. The exception is if you have X terminals or diskless workstations attached directly to your Linux system. Another question asked with later versions of Linux relates to IPX protocol support. The IPX protocol is used with Novell NetWare; you can ignore it unless your Linux system is part of a NetWare network that doesn't use TCP/IP.
Other questions that may get asked relate to network masks, algorithms used, and dummy driver support, which is a loopback mechanism. In almost all cases, you are safe using the default answers provided by the configuration routine unless you specifically want to override a setting. If you indicated that your system is using a network adapter board, you are asked more questions about the type of support you need for the board. Most versions of Linux go through a series of popular network cards and ask which one you want support for. Choose the network card that matches yours, or choose one that is supported by emulation.
After you have specified all the protocols you want to support, the kernel rebuilds. The rebuilt kernel doesn't enable all the protocols, but it does add the drivers to the kernel. You still have to activate the protocols in the configuration routines and startup process.
Forcing a Network Card Recognition
If the autoprobe routine in the Linux kernel doesn't recognize your network card, you must specifically tell it the network card's configuration. You can do this task by adding information to the boot process or by embedding configuration information within the startup information the kernel uses.
To add network card information to the boot process, use LILO. The routine lilo.conf (see Chapter 4, "LILO") enables you to issue an append instruction, after which you can enter a line that provides the device parameters. The format for the instruction to add an Ethernet card is as follows:
In this code, IRQ is the IRQ setting, Address is the base I/O address of the network board, PARM1 and PARM2 are optional parameters that some boards use, and NAME is the name of the device. Usually boards use the optional parameters to set starting and ending addresses of shared memory boards (if they are supported), although some boards use them to set a debug level. For more information on the values to use for these parameters, see the list of network cards supported by Linux that is included with your Linux distribution, or check BBSs, FTP sites, or the Linux newsgroups on USENET.
This command format is quite easy to use. For example, after issuing the append instruction in lilo.conf, you can specify the following line:
This line sets the device /dev/eth0 with IRQ 5 and base address 220H. The zeros for the parameters mean no value for most boards. If you want LILO to invoke the kernel's autoprobe routine, leave the values for IRQ and the I/O address set to zero.
To embed configuration information within the startup information the kernel uses, edit the file drivers/net/Space.c in the kernel source code directory. (Some Linux versions use a different path, but the file Space.c should exist). Use this approach only if you are familiar with network boards and their settings. The LILO approach is much more preferable.
When you have the Linux kernel configured to handle the network board, reset the machine and watch the startup messages. These messages should include a message indicating the network board has been successfully found. (If the messages scroll by too quickly for you to read, use the dmesg command to recall them from the shell prompt.) For example, the following prompts are displayed during system boot to indicate recognition of a Novell NE2000 Ethernet card:
NE*000 ethercard probe at 0x300: 00 00 6e 24 1e 3e eth0: NE2000 found at 0x300, using IRQ 15.
Setting Up PLIP
PLIP (Parallel Line IP) is a method of networking two machines together using their parallel ports. PLIP uses a special cable that allows sustained transfer speeds up to 20kbps. The cable required is a null printer cable that crosses some pins. The cables from parallel port versions of some PC-to-PC software packages like LapLink also work.
If you want to make your own PLIP cable, use the following pin-out settings at each end:
|connector 1 pin||connector 2 pin|
All other pins are unconnected. Disconnect the shielding at one end as well.
If you select the PLIP option in the kernel configuration, the device drivers for PLIP are set up as /dev/plip0 (IRQ 7, I/O 3BC), /dev/plip1 (IRQ 7, I/O 378), and /dev/plip2 (IRQ 5, I/O 278). The IRQ and base I/O address settings are those of the normal parallel port IRQs and addresses on a PC and shouldn't be changed unless you modified the parallel port settings in the Linux kernel. When you connect your machine to another machine, your machine's /dev/plip0 connects to /dev/plip1 on the other machine, and the other machine's /dev/plip0 connects to your machine's /dev/plip1.
Setting Up SLIP and PPP Serial Ports
Both SLIP and PPP use a serial port that is already configured on the Linux system, so no hardware configuration is required. Before running SLIP or PPP, however, you should check that the serial ports are configured properly. The serial ports on the PC are recognized as /dev/cua when used to drive modems, so you can perform a quick directory check to see whether they are already configured for you. Use the command
ls -l /dev/cua*
to display all the serial modem devices. You should see four devices configured, with the output shown like the following listing:
crw-rw-rw- 1 root root 5, 64 Mar 14 12:26 /dev/cua0 crw-rw-rw- 1 root root 5, 65 Mar 14 12:26 /dev/cua1 crw-rw-rw- 1 root root 5, 66 Mar 14 12:26 /dev/cua2 crw-rw-rw- 1 root root 5, 67 Mar 14 12:26 /dev/cua3
The dates and creation times may be different, but the device major and minor numbers, as well as the device names, should be the same. If these devices do not show up in your /dev directory, create them with the mknod command (see Chapter 6, "Devices and Device Drivers"). For example, to set up the four devices shown in the preceding code, issue the following commands:
mknod -m 666 /dev/cua0 c 5 64 mknod -m 666 /dev/cua1 c 5 65 mknod -m 666 /dev/cua2 c 5 66 mknod -m 666 /dev/cua3 c 5 67 chown root.root /dev/cua*
The last command changes the ownerships of the device drivers. You can also set up a link to the device name /dev/modem with the following command:
ln /dev/cua0 /dev/modem
Substitute whichever device is your default modem device, such as /dev/cua1 if you haven't created a link between the device and /dev/modem. If you have a link between the modem device and the device called /dev/modem, don't use both /dev/modem and the actual device names intermingled in your software or device conflicts can occur. When you start one software application that uses /dev/modem, it creates a set of lock files for /dev/modem. If you then start another application using the device's real name, such as /dev/cua1, the second application creates lock files for /dev/cua1, not realizing the device is already in use under the name /dev/modem.
When Linux restarts, you should see messages during the system boot that show the PPP, PLIP, or SLIP device drivers (whichever were linked into the kernel) being loaded. You can replay the boot messages with the dmesg command. The following startup messages show the PPP and SLIP drivers:
PPP: version 0.2.7 (4 channels) NEW_TTY_DRIVERS OPTIMIZE_FLAGS PPP line discipline registered. SLIP: version 0.8.3-NET3.019-NEWTTY (4 channels) (6 bit encapsulation enabled)
This chapter examined the changes that you must make to the kernel to provide networking support and create the hardware and device driver files necessary to run networks. After you reconfigure and reboot the kernel, and the kernel properly recognizes the new devices, you can go on to configure the network software.
Только зарегистрированные пользователи могут оценивать и комментировать статьи.