NICs are the most important network devices on Linux servers. According to statistics, 35% of Linux network faults are at the physical layer, 25% at the data link layer, 10% at the network layer, 10% at the transmission layer, 10% at the conversation layer, 7% at the presentation layer, and 3% at the application layer. It can be seen that network faults usually occur on the lower layer of the layer-7 network model, that is, the physical layer, link layer, and network layer. The corresponding Nic is the most important network device on a Linux server. According to statistics, 35% of Linux network faults are at the physical layer, 25% at the data link layer, 10% at the network layer, 10% at the transmission layer, 10% at the conversation layer, 7% at the presentation layer, and 3% at the application layer. It can be seen that network faults usually occur on the lower layer of the layer-7 network model, that is, the physical layer, link layer, and network layer. Corresponding to the actual network, that is, the used network cables, network adapters, switches, routers, and other equipment faults. Linux network implementation is similar to FreeBSD. it supports FreeBSD's extended Sockets (socket) and TCP/IP protocols. It supports the network connection between two hosts and the Sockets communication model, and implements two types of Sockets: BSD Sockets and INETSockets. It provides two transmission protocols for different communication models and service quality, namely, unreliable, message-based UDP transmission protocol and reliable, stream-based transmission protocol TCP, it is also implemented on the IP network protocol. INET sockets is implemented based on the above two protocols and IP protocols.
Because vswitches and vrouters are generally independent of Linux or other operating systems. Nic configuration failure is the main cause of Linux server failure. It may be caused by hardware quality or performance, wear and aging, human error, incorrect network settings, management problems, Linux software bugs, hacker attacks, and Linux viruses.
For Linux server NIC troubleshooting, we should follow the hardware first and software method. If the hardware is physically damaged, how to set the Nic cannot solve the fault. To solve the problem, you can check the network card of your Linux computer. if the hardware is correct, consider the software settings.
1. Nic selection
Generally, Linux versions later than version 2.4 support a complete number of network card chipsets, including well-known vendors such as Intel and widely used RealTek and Via Nic chips, therefore, users can easily set their network cards. However, due to the large number of Linux releases (more than 188 at present), it is best to view the documentation of the Linux release before use. Take RedhatLinux 9.0 as an example. the device list is in the Ethernet-HOWTO document. In addition, the most direct method is to view a directory:/lib/modules/release/kernel/drivers/net, where release is the kernel version and can be obtained using the command "uname-r. For Redhat Linux 9.0, the value is 2.4.20-8.
# Ls/lib/modules/2.4.20-8/kernel/drivers/net/
3c501. o atp. o eth16i. o ni52.o smc-ultra.o
3c503. o bonding. o ethertap. o ni65.o starfire. o
3c505. o cs89x0. o ewrk3.o ns83820.o strip. o
3c507. o de4x5. o fc pcmcia sundance. o
3c509. o de600.o fealnx. o pcnet32.o sungem. o
3c515. o de620.o hamachi. o plip. o sunhme. o
3c59x. o defxx. o hamradio ppp_async.o tc35815.o
8139cp. o depca. o hp100.o ppp_deflate.o tg3.o
8139too. o dgrs. o hp. o ppp_generic.o tlan. o
82596. o dl2k. o hp-plus.o ppp_synctty.o tokenring
8390. o dmfe. o irda r8169.o tulip
Ac3200.o dummy. o lance. o rcpci. o tulip_old
Acenic. o e100 lne390.o sb1000.o tun. o
Aironet4500_card.o e1000 lp486e. o shaper. o via-rhine.o
Aironet4500_core.o e2100.o mii. o sis900.o wan
Aironet4500_proc.o eepro100.o natsemi. o sk98lin wavelan. o
Amd8111e. o eepro. o ne2k-pci.o skfp wd. o
Appletalk eexpress. o ne3210.o slhc. o winbond-840.o
Arlan. o epic100.o ne. o slip. o wireless
Arlan-proc.o eql. o netconsole. o smc9194.o wireless_old
At1700.o es3210.o ni5010.o smc-ultra32.o yellowfin. o
You can see that this directory lists all network device drivers supported by the Linux kernel. Most of them are Ethernet cards (8139, 3COM, Intel ). There are also some other types of devices. For beginners, try to select the Nic already listed in the directory. Note that the file ended with the. o suffix is the driver. The driver Directory (red) is not suffixed ).
3. set an IP address for the new NIC
An alias is assigned to a Linux network device during configuration. the alias consists of a descriptive acronyms and a number. The first device of a certain type is numbered 0, and other devices are numbered 1, 2, 3, and so on. However, the NIC is not the most bare device in the/dev directory, but in the memory. Eth0 and eth1 are Ethernet interfaces. They are used for most Ethernet cards, including many parallel port Ethernet cards. This article mainly discusses this type of Nic. You can set an IP address for a Linux Ethernet card in a very flexible way. you can choose a method suitable for your work:
(1) use the ip address or ifconfig command
The ifconfig command is the most important Linux Network command. The main purpose is to set and modify the IP address of the NIC and the IP address of the NIC:
# Ifconfig eth0 192.168.0.2 netmask 255.255.255.0
By default, ifconfig displays active network devices. Add a-a switch to this command to view all devices. However, the ifconfig command sets the IP address of the network device. after the system restarts, the setting will automatically fail. Therefore, it is mainly used for NIC status debugging. Suppose you want to create a temporary network configuration for testing. You can use the tool in the release version to edit the configuration, but note that after the test is completed, all the settings are restored. By using ifconfig, we can quickly configure the Nic without affecting the saved settings.
The Ip command is a powerful network configuration tool in the iproute2 software package. it can replace some traditional network management tools. For example, ifconfig and route. Currently, most Linux distributions and most UNIX use the old arp, ifconfig, and route commands. Although these tools can work, they seem outdated in Linux and later. Before using iproute2, you should confirm that this tool has been installed. The package name in RedHatLinux 9.0 is called "iproute2", you can also download the source code installation in: ftp://ftp.inr.ac.ru/ip-routing.
If you want to add an address 10.0.0.1 to the Ethernet interface eth0, the mask length is 24 bits, the standard broadcast address, and the label is eth0: Alias:
# Ip addr add 10.0.0.1/24 brd + dev eth0 label eth0: Alias
The netconfig command can be used to set the IP address of a network device. the netconfig command can be used to permanently save the settings.
Use "netconfig ethX ". After the "netconfigeth0" command is run, a dialog box is displayed on the command line.
After the setting is complete, press "tab" and select "OK" to save the setting and exit. Then run the command "service network restart" to activate the service.
To use the neat command, you need to configure the Xwindow system. run the "neat" command on the command line, add the IP address and other related parameters, and save the settings to restart the network and network service or computer.
In addition, the neat Command also has the same price command: "redhat-config-network", which is exactly the same. The Neat and redhat-config commands can permanently save the settings.
Unless otherwise specified, most configuration files in Red Hat Linux are in the/etc directory. The NIC-related TCP/IP network configuration file is:/etc/sysconfig/network-scripts/ifcfg-ethx. Where x starts from 0, the first Ethernet Configuration file is:/etc/sysconfig/network-scripts/ifcfg-eth0. You can use the vi editor to modify the file or the IP address of the NIC.
# Vi/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE = eth0 # set the network card name, which must correspond to the file name #
ONBOOT = yes # whether to enable the NIC at startup #
BOOTPROTO = static # The Protocol obtained by the IP address at startup, which is fixed here,
If it is a dynamic host, it must be changed to dhcp #
IPADDR = 192.168.1.2 # IP address #
NETMASK = 255.255.255.0 # subnet mask #
NETWORK = 192.168.1.0 # The first IP address of the NETWORK segment #
BROADCAST = 192.168.1.255 # BROADCAST address of the last same network segment #
GATEWAY = 192.168.1.2 # GATEWAY address #
# GATEWAYDEV = eth0
After saving the disk, run the command "service network restart" to activate it. This method can also save settings permanently.
(5) add an IPV6 address for the NIC
Compared with Windows systems, Linux provides better Ipv6 support. The earliest Linux kernel that supports Ipv6 is 2.2.xxx. Generally, Ipv6 can be used directly for Linux versions based on the 2.4 Kernel. before using IPv6, you must check whether the system Ipv6 module is loaded. if not, you can use commands to manually load the system, this requires the permissions of the Super User. Run the command to check whether the IPv6 address (inet6addr: fe80: 200: e8ff: fea0: 2586/64) indicates that IPv6 has been loaded.
# Modprobe IPv6; # ifconfig-
If you want to automatically load the Ipv6 module when the Linux system starts, you can add a line in the configuration file:/etc/modules. conf:
Alias net? Pf? 10 ipv6 # automatically load IPv6 module ondemand
4. adjust the Nic working mode
Currently, most network interfaces work in adaptive mode. when configuring network interface parameters, we seldom consider the network interface mode. sometimes we find that some network interface modules have been loaded, but they are unstable in some modes. For example, I use a XXX brand of miscellaneous card RTL-8139C chip 10/100 adaptive Nic in 100 full duplex state is extremely unstable (in the Qcheck TCP and UDP test process, the packet loss rate is 9.12% .). In Linux, we can use the mii-tool Command provided by the system to configure the Nic working mode. Display all the Ethernet card types supported by the Linux server NIC. run the following command:
# Mii-tool-v
Eth0: negotiated 100baseTx-FD, link OK
Product info: vendor 00:00:00, model 0 rev 0
Basic mode: autonegotiation enabled
Basic status: autonegotiation complete, link OK
Capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD10baseT-HD
Advertising: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
Link partner: 100baseTx-FD 100baseTx-HD 10baseT-FD10baseT-HD
From the above information, we can see that this network card works in 100 full duplex adaptive mode, and "100aseTx-FD" means 100 M FullDuplex. Here, you can force the NIC to work in m half-working mode and enter the command:
# Mii-tool? F 100baseTx-HD eth0
To recover the adaptive working mode of the network adapter in the future, enter the following command:
# Mii-tool? R eth0
In addition, the correct working mode should be specified for routers, switches, proxy servers, and other key devices with large traffic, which can improve the communication efficiency.
5. DHCP client Nic settings
If you want to use DHCP as a Dynamic Host Configuration Protocol, this protocol is used to automatically provide IP addresses, subnet masks, and routing information to your computer. When devices access this Lan, they will request an IP address from the DHCP server. The DHCP server then assigns an address to each requested device until all IP addresses in the specified range are allocated. The allocated IP address must be regularly extended. This extension process is called leasing, which ensures that the allocated address can be returned to the server when the client device suddenly disconnects from the network before the IP address is released normally. There are two ways to configure the DHCP client in Linux: graphical interface and manual configuration. You can use the neat command interface on the GUI. Select "automatically obtain IP address settings and use DHCP.
I usually prefer to manually configure DHCP clients. you need to modify the/etc/sysconfig/network file to enable the networking; modify the configuration file of each network device in the/etc/sysconfig/network-scripts directory. In this directory, each device has a configuration file named ifcfg-ethX, which is the name of the network device. Such as eth0. If you want to enable NETWORKING during boot, the NETWORKING variable must be set to yes. Except here, the/etc/sysconfig/network file should contain the following lines:
NETWORKING = yes
DEVICE = eth0
BOOTPROTO = dhcp
ONBOOT = yes
6. VPN server NIC settings
VPN is a secure communication tunnel established on the Internet by authorized communication parties. data is encrypted in the tunnel for secure communication between headquarters and branches. Virtual private network is a new network technology used to securely access the enterprise network over the Internet or LAN. In Redhat Linux, the VPN technology mainly includes CIPE (Crypto IPEncapsulation: encrypted IP encapsulation), which is mainly developed for Linux. CIPE uses encrypted IP groups. these groups are encapsulated or "surrounded" in the datagram (UDP) group. The CIPE group is given the target header information and encrypted using the default CIPE encryption mechanism. CIPE uses standard Blowfish or IDEA encryption algorithms to support encryption. Depending on the encryption export regulations in your country, you can use the default method (Blowfish) to encrypt all the CIPE traffic on your private network. The CIPE configuration can be completed through text files and graphical network management tools. This section uses a text file as an example. First, install the CIPE software on the server and client. Official website: http://sites.inka.de /~ To run the CIPEVPN service, you must create two files:/etc/sysconfig/network-scripts/ifcfg-cipcbX and/etc/cipe/options. cipcbX. X is an incremental number starting from 0.
(1) VPN server NIC settings
First, manually create the/etc/sysconfig/network-scripts/ifcfg-cipcb0 file, it is the virtual network interface of the VPN server, the main content:
USERCTL = yes # whether to allow all users to modify the configuration #
TYPE = CIPE # interface TYPE #
DEVICE = cipcb0 # Name the cipe device #
ONBOOT = yes # activate the device when the system starts #
IPADDR = 10.0.0.1 # Local virtual address #
MYPORT = 7777 # communication port #
PTPADDR = 10.0.0.2 # remote virtual address #
PEER = 0.0.0.0 # local address, 0.0.0.0 indicates accepting continuous listening #
ME = 192.168.1.9 # cipe udp address #
TUNNELDEV = eth0 # tunnel device #
Then create the/etc/cipe/options. cipcb0 file, which stores the key and main content:
Cttl 64 # set the carrier TTL value. The recommended value is 64 #
Maxerr? 1 # server error suspension time #
Key 54240266869983357939377846801171299051 #128-bit key #
(2) client Nic configuration
Because CIPE requires that the keys of the server and client be identical, first copy the key File: options. cipcb from the server to the/etc/cipe/directory of the client host.
# Scp root@192.168.1.9:/etc/cipe/options. cipcb0/etc/cipe/options. cipcb0
Are you sure you want to continue connecting (yes/no )? Yes
Warning: Permanently added '192. 168.1.9 '(RSA) to the list ofknown hosts.
Root@192.168.1.9's password:
Options. cipcb0 100% | ************************************* ** | 6100: 00
Then use the vi editor to create the client Nic configuration file:/etc/sysconfig/network-scripts/ifcfg-cipcb0 contains the following:
USERCTL = no # The client is not allowed to modify the configuration #
BOOTPROTO = none
TYPE = CIPE # interface TYPE #
DEVICE = cipcb0 # Name the cipe device #
ONBOOT = yes # activate the device when the system starts #
IPADDR = 10.0.0.2 # Local virtual address #
MYPORT = 7777 # communication port #
PTPADDR = 10.0.0.1 # remote virtual address #
PEER = 192.168.1.29: 7777 # real IP address and port number of the VPN server #
ME = 192.168.1.9 # cipe udp address #
TUNNELDEV = eth0 # tunnel device #
MTU = "" # use the default settings #
NETMASK = "" # use the default settings #
NETWORK = "" # use the default settings #
BROADCAST = "" # use the default settings #
(3) use the ifup command to activate the VPN Nic
# Ifup cipcb0
The VPN channel is enabled.
TcpdumpAnd other tools.
7. install wireless NICs in Linux
With the rapid growth of Linux network technology, hardware vendors have greatly accelerated the technical support for hardware products for Linux. The number of wireless NICs supported by Linux has increased significantly over the past one or two years. Once the Wireless NIC is installed on the computer, the first thing to do is to install the driver to make the Nic work. The wireless network card provides one or more physical layer (PHY) and media access control sub-layer (MAC) functions in the series protocol, and the driver is used to control the wireless network card, provides interfaces that are the same as those of Ethernet and some other management interfaces specific to the wireless LAN. There is no unified method for driving all NICs from different vendors. First, make sure that the wireless LAN is enabled in the kernel configuration. If you do not have Wireless LAN support, you should reconfigure and compile the kernel to start "WirelessLAN (non-hamradio) Drivers and Wireless Extensions ".
Currently, most of the common wireless network interfaces are PCMCIA, PCI, and USB. The most commonly used wireless network interfaces are those of the PCMCIA (PersonalComputer Memory Card InternationalAssociation) interface. For some devices, it is very easy to configure wireless connections: you only need to insert the wireless network card in the Linux version you are using, click the mouse during the setting process, and enter the correct networking parameters. Generally, the installation of Wireless NICs based on the Lucent chipset is relatively simple. the CiscoAironet Wireless 802.11b installation program used by the author can smoothly find the device driver in the Mandrake 8.2 Linu installation program, installing a PCMCIA wireless Nic based on the intersil PRISM2-based cards chipset is complicated. Install a third-party tool.
Currently, two types of PCMCIA NICs have been certified by www.Linux.org. See Table 1 for PCIMCIA wireless NICs using the Lucent chipset and PCMCIA using the intersilPRISM2-based cards chipset.
Lucent chipset-based cards intersil PRISM2-based cards
Lucent Wavelan/IEEE and Orimoco Linksys (WPC11 v2.5)
Cabletron/Enterays RoarmAbout SMS (2632 W)
Compaq (WL110, WL210, WL215) Compaq (WL100, WL200)
Apple Airport Cisco Aironet Wireless 802.11b (340, 350)
IBM High Rate Wireless LAN Dlink DWL-650
HP 802.11 bWiewless LAN Nokia
DELL TrueMobile Intel PRO/Wireless 2100
3Com AirConnect SAMSUNG 11 Mbps WLAN Card
LA4111 Spectrum24 Wireless lan pc Card proxim lan pc cardharmony 80211B
NCR WaveLAN/IEEE Adapter
In general, the installation sequence of wireless NICs in Linux is:
Install the Linux distribution in full mode, re-compile the kernel, and remove any part of the PCMCIA driver provided to the kernel.
Learn about Nic specifications and download and compile appropriate PCMCIA-CS libraries and drivers
Download, compile, and install all drivers required for the wireless network adapter. This step is optional for some NICs and required for some NICs. Whether or not it works depends largely on the selected wireless network adapter.
Modify the settings of the wireless network card. Restart the Linux system and network.
To set up a wireless network, follow these steps:
(1) run the "iwconfig" command to display information about the wireless network adapter (eth0, eth1. In the following steps, use ethX to indicate the name of the wireless network adapter.
(2) set the operation mode of the wireless network card to Managed:
# Iwconfig ethX mode Managed
(3) If WEP encryption is used, you need to set the WEP password:
# Iwconfig ethX key password XXXXXX
It is encrypted with 40-bit and 128-bit passwords, which are 6-bit and 10-bit hexadecimal numbers respectively.
(4) set the SSID, where ESSID is the SSID of the wireless Access Point.
# Iwconfig ethX essid ESSID
(5) create the/etc/sysconfig/network/ifcfg-ethX configuration file so that the wireless network adapter automatically obtains the IP address each time the machine starts. The file content is as follows:
BOOTPROTO = 'dhcp'
MTU =''
REMOTE_IPADDR =''
STARTMODE = 'onboot'
UNIQUE =''
(6) start the wireless network card:
# Ifconfig ethX up
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