How to use the ping command to diagnose the network in Linux system

  

The ping command is a command for network diagnosis in Linux system. It can check whether the network is connected. It is usually used to analyze and judge network faults. It is a very used command. Let me introduce you how to use the ping command under Linux. Let's take a look at it.

, by sending ICMP ECHO_REQUEST packets to a network host (send ICMP ECHO_REQUEST to network hosts), and the response of the display, so that we can determine whether the target host can access information according to its output ( But this is not absolute). In order to prevent detection by ping, some servers set a prohibition ping through the firewall or disable ping in the kernel parameters. Therefore, it is impossible to determine whether the host is still open by ping.

The ping under linux is slightly different from the ping under windows. The ping under linux will not be automatically terminated. You need to terminate by ctrl+c or specify the number of responses required by parameter -c.

1. Command format:

ping [parameter] [host name or IP address]

2. Command function:

The ping command is used to: Determine the status of the network and external hosts; track and isolate hardware and software issues; test, evaluate, and manage the network. If the host is running and connected to the network, it responds to the loopback signal. Each echo signal request contains an Internet Protocol (IP) and ICMP header followed by a tim structure and enough bytes to fill in the packet. The default is to continuously send a loopback request until an interrupt signal is received (Ctrl-C).

The ping command sends one datagram per second and prints one line of output for each response received. The ping command calculates statistics on signal round-trip time and (information) packet loss and displays a brief summary after completion. The ping command ends when the program times out or when a SIGINT signal is received. The Host parameter is either a valid host name or an Internet address.

3. Command parameters:

-d Use the SO_DEBUG function of Socket.

-f Limit detection. Send large and fast network packets to a machine to see its response.

-n Only output values.

-q Does not display any information about the transmitted packet, only the last result.

-r Ignore the normal Routing Table and send the packet directly to the remote host. Usually it is a problem to check the network interface of this machine.

-R Records the routing process.

-v Detailed display of the execution of the instruction.

Number of p--c: Stops after sending the specified number of packets.

-i Seconds: Set a few seconds to send a network packet to a machine. The default value is one second.

-I Web Interface: Sends a packet using the specified web interface.

-l Preload: Sets the packet to be sent before sending the request message.

-p Template Style: Set the template style to fill the packet.

-s Bytes: Specifies the number of bytes of data to be sent. The default value is 56, plus an 8-byte ICMP header, which is a total of 64 ICMP data bytes.

-t Survival value: Set the size of the surviving value TTL.

4. Use case:

Instance 1: ping pass

Command: ping 192.168.120.205

Output:

The code is as follows:

[root@localhost ~]# ping 192.168.120.205

PING 192.168.120.205 (192.168.120.205) 56(84) bytes of data.

64 bytes from 192.168.120.205: icmp_seq=1 ttl=64 time=0.720 ms

64 bytes from 192.168.120.205: icmp_seq=2 ttl=64 time=0.181 ms

64 bytes from 192.168 .120.205: icmp_seq=3 ttl=64 time=0.191 ms

64 bytes from 192.168.120.205: icmp_seq=4 ttl=64 time=0.188 ms

64 bytes from 192.168.120.205: icmp_seq =5 ttl=64 time=0.189 ms“/p” “p”--- 192.168.120.205 ping statistics ---

5 packets transmitted, 5 received, 0% packet loss, time 4000ms

rtt min/avg/max/mdev = 0.181/0.293/0.720/0.214 ms

[root@localhost ~]#
Previous123Next 3

Copyright © Windows knowledge All Rights Reserved