How to install and configure network devices on Linux

Source: Internet
Author: User
Tags network function domain name server netconf
Article Title: How to install and configure network devices on Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Since the birth of linux, it has been doomed to an unprecedented powerful network function. Therefore, it is very important to configure the network in linux to make it efficient and secure. Next we will introduce the network settings in linux from three aspects: network device installation, network service settings, and network security.

When installing linux, if you have a Nic, the installer will prompt you to provide TCP/IP network configuration parameters, such as the local ip address, the default gateway ip address, and the DNS ip address. Based on these configuration parameters, the installer automatically compiles the NIC (which must be supported first in linux) driver into the kernel. But we must understand the process of loading the NIC driver, so we will be very easy to operate when we change the Nic later and use multiple NICs. Nic drivers are loaded into the kernel as modules. all Nic drivers supported by linux are stored in the directory/lib/modules/(linux version)/net /, for example, the driver of the inter 82559 series 10/100 M adaptive boot Nic is eepro100.o, and the driver of 3C509 ISA Nic of 3COM is 3C509. o, DLINK pci 10 NIC driver is via-hine.o, NE2000 compatible NIC driver is ne2k-pci.o and ne. o. after learning about these basic drivers, we can change or add NICs by modifying the module configuration file.

1. modify the/etc/conf. modules file

This configuration file is an important parameter file for loading modules. let's take a look at an example file.

#/Etc/conf. modules

Alias eth0 eepro100

Alias eth1 eepro100

This file is the content in conf. modules in a linux system with two inter 82559 series NICs. The alias command indicates the name of the driver of the Ethernet port (such as eth0). The alias eth0 eepro100 indicates that the driver to be loaded on the Ethernet port 0 is eepro100.o. when modprobe eth0 is used, the system automatically loads eepro100.o to the kernel. For pci NICs, because the system will automatically find the NIC's io address and interrupt number, it is not necessary to use options in conf. modules to specify the NIC's io address and interrupt number. But corresponding to the ISA Nic, you must specify the hardware I/O address or interrupt number in conf. modules, as shown below, indicating the conf. modules file of an ISA Nic of NE.

Alias eth0 ne

Options ne io = 0x300 irq = 5

After modifying the conf. modules file, run the following command to load the module:

# Insmod/lib/modules/2.2.14/net/eepro100.o

In this way, you can load the module eepro100.o at the Ethernet port. you can also run the following command to view the information of the currently loaded module:

[Root @ ice/etc] # lsmod

Module Size Used

Eepro100 15652 2 (autoclean)

The returned result indicates that the currently loaded module is eepro100, with a size of 15652 bytes and two users. the returned result is cleared automatically.

2. modify the/etc/lilo. conf file.

In some newer linux versions, because the operating system automatically detects all related hardware, you do not have to modify the/etc/lilo. conf file. However, for the ISA Nic and old version, you can modify the lilo. conf file to initialize the newly added Nic in system initialization. Add the following command to the/etc/lilo. conf file:

Append = "ether = 240x300, eth0 ether = x, eth1"

This command indicates that the io address of eth0 is 0x240, the interrupt is 5, the io address of eth1 is 0x300, and the interrupt is 7.

In fact, this statement comes from the parameters passed when the system guides the image file,

LILO: linux ether = 240x300, eth0 ether = x, eth1

This method also enables the linux system to configure two NICs. Similarly, when using more than three NICs, you can follow the same method.

After configuring the network card, you should configure the TCP/IP parameters. In general, you will be prompted to configure the network parameters while installing the linux system. If you want to modify the network settings, run the following command:

# Ifconfig eth0 A. B .C.D netmask E.F. G. H

A. B .C.D is the IP address of eth0, and E.F. G. H is the network mask.

In fact, in linux, we can set multiple IP addresses for a network card, for example, the following command:

# Ifconfig eth0: 1 202.112.11.218 netmask quota limit 192

Then, run the command # ifconfig-a to view the interfaces of all network interfaces:

Eth0 Link encap: Ethernet HWaddr 00: 90: 27: 58: AF: 1A

Inet addr: 202.112.13.204 Bcast: 202.112.13.255 Mask: invalid bandwidth limit 192

Up broadcast running multicast mtu: 1500 Metric: 1

RX packets: 435510 errors: 0 dropped: 0 overruns: 0 frame: 2

TX packets: 538988 errors: 0 dropped: 0 overruns: 0 carrier: 0

Collisions: 318683 txqueuelen: 100

Interrupt: 10 Base address: 0xc000

Eth0: 1 Link encap: Ethernet HWaddr 00: 90: 27: 58: AF: 1A

Inet addr: 202.112.11.218 Bcast: 202.112.11.255 Mask: invalid bandwidth limit 192

Up broadcast running multicast mtu: 1500 Metric: 1

Interrupt: 10 Base address: 0xc000

Lo Link encap: Local Loopback

Inet addr: 127.0.0.1 Mask: 255.0.0.0

Up loopback running mtu: 3924 Metric: 1

RX packets: 2055 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 2055 errors: 0 dropped: 0 overruns: 0 carrier: 0

Collisions: 0 txqueuelen: 0

We can see three network interfaces: eth0, eth0: 1, lo, and eth0 are real Ethernet interfaces. eth0: 1 and eth0 are the same network interfaces, only when another address is bound, lo will send the address. Eth0 and eth0: 1 can use IP addresses of different network segments, which is useful when different network addresses are used for the same physical network segment.

In addition, the NIC has a prosimc mode. In this mode, the NIC will receive all the packets in the network. some network listening tools in linux, such as tcpdump, snort and so on are all set to the mixed mode Nic.

The ifconfig command can change the IP address of the NIC during the running time. However, if the system restarts, linux still starts the network interface according to the default settings. At this time, you can use the netconfig or netconf command to reset the default network parameters.

The netconfig command is used to reconfigure basic TCP/IP parameters, including whether to dynamically obtain the ip address (dhcpd and bootp), the ip address of the NIC, and the network mask, default Gateway and preferred domain name server address. The netconf command can be used to configure all network parameters in detail, including client tasks, server tasks, and other configurations. in the client configuration, it mainly includes the configuration of the basic host (host name, valid domain name, network alias, IP address corresponding to the corresponding Nic, network mask, network device name, kernel driver of the network device), DNS address configuration, the default gateway address configuration, NIS address configuration, ipx interface configuration, ppp/slip configuration, and so on. The server configuration mainly includes NFS configuration, DNS configuration, ApacheWebServer configuration, Samba configuration, and Wu-ftpd configuration. Among other configuration options, one is about the host configuration in the/etc/hosts file, and the other is about the network configuration in the/etc/networks file, finally, the information about the use of linuxconf configuration.

You can also configure network information under the linuxconf command, but you can find that the linuxconf program calls netconf for network configuration.

In addition, the system's network configuration file is stored in the/etc/sysconfig/network-scripts directory. The example is as follows:

Ifcfg-eth0 * ifdown-post * ifup-aliases * ifup-ppp *

Ifcfg-eth1 * ifdown-ppp * ifup-ipx * ifup-routes *

Ifcfg-lo * ifdown-sl * ifup-plip * ifup-sl *

Ifdown @ ifup-post * network-functions

The ifcfg-eth0 is the configuration information of the Ethernet port eth0, its content is as follows:

DEVICE = "eth0"/* specify the name of the network DEVICE */

IPADDR = "202.112.13.204"/* specify the IP address of the network device */

NETMASK = "255.255.255.255.192"/* specify the network mask */

NETWORK = 202.112.13.192/* specify the NETWORK address */

BROADCAST = 202.112.13.255/* specify the BROADCAST address */

ONBOOT = "yes"/* indicates whether to activate the Nic when the system starts */

BOOTPROTO = "none"/* indicates whether the bootp protocol is used */

Therefore, we can modify this file to change the network parameters in linux.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.