1.4 common system maintenance commands

Source: Internet
Author: User
Tags traceroute command

Linux supports many commands, but due to the length, this book cannot introduce all commands. It only describes some frequently used commands to save readers time.

1.4.1 Nic settings-ifconfig command

The NIC can be said to be one of the most important components in network communication. It is not only responsible for data transmission, but also ensures the security during transmission. Therefore, the Administrator must be familiar with the NIC settings, to cope with changes in the network environment. Ifconfig is one of the most important commands when setting Nic configurations. It can be used to display and set Nic configurations, such as IP addresses, subnet masks, IRQ, and IO ports.

Display Nic Information

If you run the ifconfig command without adding any parameters, the current Nic information of the system is displayed. Eth0 and lololoopback are displayed on the client that contains a network card. If the client is using a modem for dial-up, the ppp0 and lo interfaces are displayed. The following is a client configuration example with a NIC:

[root@ns1 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:48:40:30
inet addr:192.168.0.118 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe48:4030/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2987 errors:0 dropped:0 overruns:0 frame:0
TX packets:3044 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2886858 (2.7 MiB) TX bytes:403985 (394.5 KiB)
Interrupt:16 Base address:0x1080

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:2372 errors:0 dropped:0 overruns:0 frame:0
TX packets:2372 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2463105 (2.3 MiB) TX bytes:2463105 (2.3 MiB)

The above results can be divided into two parts: eth0 and lo, which contain similar projects. Because many of them are important proprietary terms in the Internet, this book explains the meaning and usage of each term one by one:

ナ Link encapLink encapsulate)
A method used to divide information into groups, such as Ethernet.
ナ HwaddrHardware address)
Indicates the hardware address of the network card, also known as MACMedia Access Control. It consists of 12 hexadecimal values, each of which is a group of two numbers separated by:, for example, 00: 0C: 29: 48: 40: 30, this number is directly burned on the NIC chip.
6 digits in the first three groups of numbers in the hardware address) indicates the code of the NIC manufacturer. Therefore, the first three groups of numbers produced by the same manufacturer are the same, for example, the D-Link code is 00: 80: C8. The last three sets of network card numbers indicate the number of the network card. Therefore, the hardware addresses of each network card are different in the world.
ナ inet addrinternet address)
Indicates the IP address of the host, which may be manually input or automatically specified by the DHCP server.
ナ BcastBroadcast)
This refers to the broadcast address used by the host. If the destination address is a broadcast address, this information can be transmitted to all computers in the same domain at the same time. Generally, the broadcast address is determined by the IP address category. Table 1-5 lists the broadcast address examples used by different IP addresses.
Table 1-5 broadcast address example

IP Class Host IP example broadcast address example

A 24.46.68.80 24.255.255.255
B 128.12.23.34 128.12.255.255
C 200.1.100.100 200.1.100.255
◆MaskNet Mask)

It refers to the subnet mask used by the Host. It is mainly used to divide the IP address into two parts: Network ID and Host ID. Simply put, the IP address and subnet mask are first converted to binary numbers, then perform the AND Operations 0 AND 0 = 0, 0 AND 1 = 0, 1 AND 0 = 0, 1 AND 1 = 1), AND the result is the Network ID.
Generally, the subnet mask varies according to the IP address category. Table 1-6 lists the subnet mask examples used by different IP addresses.
Using MTUMaximum Transmission Unit)
Indicates the maximum transmission unit of the Group during network transmission. The default value of MTU of Ethernet is 1500 Bytes.
ナ Metric
When the source host sends information to the target host, the number of forwards required, and some route communication protocols, such as RIP, must be referenced in the shortest path calculation.
Already RXReceived)
The total number of received groups, the number of lost groups, and the number of conflict.
Optional TXTransmitted)
The total number of transferred groups, the number of lost groups, and the number of conflict.
Enable and disable NICs
Displaying Nic information is only the most basic function of the ifconfig command. In addition, it can also be used to start and stop NICs. If you want to disable the eth0 Nic function, you can first specify the NIC name and then use the down parameter. If you want to restart the NIC, you need to use the up parameter. The following is a simple example:

[Root @ ns1 ~] # Ifconfig eth0 down
# Disable eth0 Nic
[Root @ ns1 ~] # Ifconfig eth0 up
# Enable eth0 Nic

Set Nic
Another function of the ifconfig command is to set the NIC, such as the IP address and subnet mask. In the following example, we will change the IP address and subnet mask of the eth0 Nic to 192.168.0.50 and 255.0.0.0 respectively:

[root@ns1 ~]# ifconfig eth0 192.168.0.50 netmask 255.0.0.0
[root@ns1 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:48:40:30
inet addr:192.168.0.50 Bcast:192.168.0.255 Mask:255.0.0.0
inet6 addr: fe80::20c:29ff:fe48:4030/64 Scope:Link
…………

Add other IP addresses to the same Nic
Currently, almost all NICs support the NDISNetwork Driver Interface Standard. That is to say, it allows multiple IP addresses to be used on the same Nic, which is quite convenient when adding virtual hosts.
Linux uses the colon :) to specify the IP address of the same Nic. For example, the first ethernet card is eth0, and the device name used to add the IP address is eth0: 1, and so on.

[root@ns1 ~]# ifconfig eth0:1 192.168.0.142
[root@ns1 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:80:C8:6F:7E:FE
inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:12486 errors:0 dropped:0 overruns:0 frame:0
TX packets:8393 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:1000548977.0 Kb) TX bytes:59547615.6 Mb)
Interrupt:10 Base address:0x5000

eth0:1 Link encap:Ethernet HWaddr 00:80:C8:6F:7E:FE
inet addr:192.168.0.142 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:10 Base address:0x5000
…………

1.4.2 check host connection-ping command
PingPacket INternet Groper) command may be a familiar network detection tool that supports this command in both Linux and Windows, and most of the parameters are similar. It is mainly used to detect whether the remote host is normal or whether the media between the two hosts is interrupted, such as network cable disconnection or network card failure.
In fact, the running principle of the ping command is very simple. It first transmits the ECHO_REQUEST packet in ICMP to the remote network host, and then the response information is used to determine the current situation of the network.
In general, if it is difficult or unable to connect to a remote host, we will try to use ping to check whether the network with the remote host is congested, the ping command is used to test the connection between the local machine and www.yahoo.com.
In addition, because ping will continuously send ICMP groups until the execution is interrupted with +, in order to avoid this situation, we use-cCounter in the following example) parameters are used to set the number of transfer groups for three times ):

[root@ns1 ~]# ping -c 3 www.yahoo.com
PING www.yahoo.akadns.net (68.142.197.88) 56(84) bytes of data.
64 bytes from p25.www.mud.yahoo.com (68.142.197.88): icmp_seq=1 ttl=48 time=206ms
64 bytes from p25.www.mud.yahoo.com (68.142.197.88): icmp_seq=2 ttl=48 time=204ms
64 bytes from p25.www.mud.yahoo.com (68.142.197.88): icmp_seq=3 ttl=47 time=210ms

--- www.yahoo.akadns.net ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 204.329/207.054/210.168/2.399 ms

From the above results, we can know the following information:
◆ IP address of the remote host, in the preceding example, 68.142.197.88.
◆ Size of the ICMP ECHO_REQUEST group, which is 64 Bytes in the preceding example.
◆ ICMP ECHO_REQUEST group ID. In the preceding example, icmp_seq = x.
◆ TTLTime To Live), in the above example, it is 48 msec.
◆ Response time, in the preceding example, time = x msec.
◆ Number of transfer groups, which is 3 in the preceding example.
◆ Transfer, receive, and group loss rate. In the preceding example, 3 packets transmitted, 3 bytes ed, 0% loss, and time 2000 ms are used.
◆ Minimum round-trip time/average round-trip time/maximum round-trip time, In the above example, rtt min/avg/max/mdev = 204.329/207.054/210.168/2.399 ms.
1.4.3 show the group history-traceroute command
Sometimes we feel that we can connect to a remote network or host, but the connection speed is very slow. In this case, using the ping command does not seem to work, because the ping command can only tell you "yes" or "no" connection, however, the connection speed or quality cannot be provided.
To solve the above problem, we need to use another common network command-traceroute, which can display the complete path of the Group transmitted from the local machine to the remote host, the connection speed of each segment is displayed to help the Administrator determine whether network congestion is caused.
In general, you can directly use the traceroute command with the target host name or IP address without using any parameters to display all the processes of group transfer, the following is a simple example:

[root@ns1 ~]# traceroute www.hinet.net
traceroute to www.hinet.net168.95.1.88),30 hops max,38 byte packets
1 172.16.11.8172.16.11.8)49.720 ms 51.800 ms 59.373 ms
2 139.175.15.1139.175.15.1)51.206 ms 64.177 ms 46.359 ms
3 R58-201.seed.net.tw139.175.58.201)59.368 ms 60.622 ms 60.229 ms
4 R58-90.seed.net.tw139.175.58.90)59.390 ms 55.093 ms 58.636 ms
5 211.22.41.174211.22.41.174)53.687 ms 57.631 ms 58.556 ms
6 211.22.35.230211.22.35.230)53.657 ms 57.724 ms 60.320 ms
7 168.95.207.97168.95.207.97)58.793 ms 59.470 ms 58.619 ms
8 w3lay4.hinet.net168.95.1.83)59.430 ms 62.363 ms 53.017 ms

From the above results, we can know the following information:
◆ The IP address of the remote host, in the preceding example, 168.95.1.88.
◆ The maximum number of vrouters allowed. In the preceding example, the value is 3030 hops max ).
◆ Transfer test, in the above example, 38 Bytes38 byte packets ).
◆ In the preceding example, each line of the actually passed vro represents each route record.
◆ The actual number of routers that have passed through. In the preceding example, there are 8 rows of records ).
◆ The time taken by the router. In the preceding example, each record contains three time records in milliseconds, which are the time when the group tries to pass through the router three times.
◆ If it is displayed as *, it indicates that the Group cannot pass the Group through the vro within the specified TTL time. It also indicates that the vro is currently busy.
According to the results obtained by executing the traceroute command, you can clearly understand the congestion of each network segment during the Group's transmission to the remote network. The data can effectively identify network problems.

BibliographyPrevious sectionNext section

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.