How to install and configure network devices on Linux system

  

From the day when Linux was born, it is destined to have unprecedented network capabilities. So how to configure the network in Linux system to make it efficient and safe. It is very important. Here we will introduce the network settings in the Linux system from three aspects: network device installation, network service settings and network security. When installing linux, if you have a network card, the installer will prompt you to give tcp /ip network configuration parameters, such as the local ip address, the default gateway ip address, DNS ip address, etc. According to these configurations Parameters, the installer will automatically compile the NIC (the linux system must first support) driver into the kernel. But we must understand the process of loading the NIC driver, then when we change the NIC in the future, when using multiple NICs, we will It will be very easy to operate. The driver of the network card is loaded into the kernel as a module. All NIC drivers supported by linux are stored in the directory /lib/modules/(linux version number)/net/, for example, inter 82595 The driver of the series 10/100M adaptive boot NIC is eepro100.o, the driver of 3COM's 3C509 ISA NIC is 3C509.o, the driver of DLINK's pci 10 NIC is via-hine.o, NE2000 compatible NIC The drivers are ne2k-pci.o and ne.o. After understanding these basic drivers, we can change the module configuration file to replace the network card or add a network card. 1. Modify the /etc/conf.modules file This configuration file is an important parameter file for loading modules. Let's look at a sample file #/etc/conf.modules alias eth0 eepro100 alias eth1 eepro100 This file is a two-block inter 92559 The contents of the conf.modules in the linux system of the series NIC. The alias command indicates the name of the driver that the Ethernet port (such as eth0) has. The alias eth0 eepro100 indicates that the driver to be loaded at the zero Ethernet port is eepro100.o. Then when using the command modprobe eth0, the system will automatically load eepro100.o into the kernel. For the pci network card, since the system will automatically find the io address and interrupt number of the network card, there is no need in conf.modules Use the options option to specify the io address and interrupt number of the NIC. But for the ISA NIC, you must specify the io address or interrupt number of the hardware in conf.modules, as shown below, indicating the conf of the NE ISA NIC. Modules file. Alias ​​eth0 ne options ne io=0x300 irq=5 After modifying the conf.modules file, you can use the command to load the module, for example to insert the second NIC of the inter: #insmod /lib/modules/2.2.14/net /eepro100.o This allows you to load the module eepro100.o in the Ethernet port. You can also use the command to view the currently loaded module information: [root@ice /etc]# lsmod Module Size Used by eepro100 15652 2 (autoclean) Back The meaning of the result is that the currently loaded module is eepro100, the size is 15652 bytes, and the user is two, the way is to automatically clear. 2. Modify the /etc/lilo.conf file In some newer Linux versions, since the operating system automatically detects all relevant hardware, there is no need to modify the /etc/lilo.conf file at this time. But for the ISA network card and the old version. In order to initialize the newly added NIC during system initialization, you can modify the lilo.conf file. Add the following command to the /etc/lilo.conf file: append="ether=5,0x240,eth0 ether=7,0x300 , eth1" The meaning of this command is 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 parameter passed when the system boots the image file, LILO: Linux ether=5,0x240, eth0 ether=7,0x300, eth1 This method can also enable the Linux system to configure two network cards. Similarly, when using three network cards, you can follow the same method. After configuring the NIC, you should configure the TCP/IP parameters. In general, you will be prompted to configure the network parameters when you install the linux system. But if we want to modify the network settings, you can use the following command: #ifconfig eth0 ABCD netmask EFGH ABCD is the IP address of eth0, EFGH is the network mask. In fact, in Linux system we can set multiple ip addresses for a network card, for example the following command: #ifconfig eth0:1 202.112.11.218 netmask 255.255.255.192 Then, you can see the interface of all network interfaces by using the command #ifconfig -a: eth0 Link encap:Ethernet HWaddr 00:90:27:58:AF:1A inet addr:202.112.13.204 Bcast:202.112.13.255 Mask: 255.255.255.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 Lin k encap:Ethernet HWaddr 00:90:27:58:AF:1A inet addr:202.112.11.218 Bcast:202.112.11.255 Mask:255.255.255.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 see that there are three network interfaces, eth0, eth0:1, lo, eth0 are real Ethernet interfaces, eth0:1 and eth0 are the same network card, but tied Set another address, lo will send the address. Eth0 and eth0:1 can use the IP address of different network segments, which is very useful when the same physical network segment uses different network addresses. In addition, the network card has a mode called prosimc. In this mode, the network card will receive all the data packets in the network. Some network monitoring tools such as tcpdump, snort, etc. under linux set the network card to promiscuous mode. . The ifconfig command can change the ip address of the NIC during the running time, but if the system is restarted, linux still starts the network interface according to the original default settings. At this time, you can use the netconfig or netconf commands to reset the default network parameters. The netconfig command reconfigures the basic tcp/ip parameters, including whether it is configured to dynamically obtain the ip address (dhcpd and bootp), the NIC address of the NIC, the netmask, the default gateway, and the preferred domain name server address. The netconf command can be used to configure all network parameters in detail. It is divided into three parts: client task, server task and other configurations. In the client configuration, the configuration of the basic host (host name, valid domain name, network alias, Corresponding to the corresponding network card's ip address, network mask, network device name, network device kernel driver), DNS address configuration, default gateway address configuration, NIS address configuration, ipx interface configuration, ppp/slip configuration, and so on. In the server-side configuration, it mainly includes NFS configuration, DNS configuration, Apache WebServer configuration, Samba configuration, and Wu-ftpd configuration. Among other configuration options, one is about the host configuration in the /etc/hosts file, one about the network configuration information in the /etc/networks file, and finally the information about using linuxconf configuration. Under the linuxconf command, you can also configure network information, but you can find that the linuxconf program calls netconf for network configuration. In addition, the system configuration file about the network is stored in the /etc/sysconfig/network-scripts directory. Examples are 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@ ifup-post* network-functions ifcfg-eth0 is the configuration information of eth0, which reads as follows: DEVICE="eth0" /* indicates the network device name*/IPADDR="202.112.13.204" /* indicates the IP address of the network device*/NETMASK="255.255.255.192" /* indicates the network mask*/NETWORK=202.112.13.192 /* indicates the network address */BROADCAST=202.112.13.255 /* indicates the broadcast address */ONBOOT="yes" /* indicates in the system Whether to activate the network card at startup*/BOOTPROTO="none" /* indicates whether to use the bootp protocol*/So, we can also modify this file to change the network parameters under Linux.

Copyright © Windows knowledge All Rights Reserved