The ping command working principle detailed

Source: Internet
Author: User
Tags firewall

In the network application, ping speed and IP address are very commonly used commands, but do you know how the ping command work? To understand the mysteries of this, it is necessary to look at what the ping command's working process is like. Next, the Green Resource Network introduces you to the details of the ping command.

Suppose host A's IP address is 192.168.1.1, Host B's IP address is 192.168.1.2, all in the same subnet, then what happens when you run "Ping 192.168.1.2" on Host a?

First, the ping command constructs a fixed format ICMP request packet, and then the ICMP protocol passes the packet along with the address "192.168.1.2" to the IP layer protocol (like ICMP, which is actually a set of background-running processes), and the IP layer protocol addresses " 192.168.1.2 "As the destination address, the native IP address as the source address, plus some other control information, to build an IP packet, and in a mapping table to find out the IP address 192.168.1.2 of the corresponding physical address (also known as MAC address, familiar with network adapter configuration friends will not unfamiliar, This is the data Link layer protocol to build the data link layer of the transmission Unit-frames required, and to the data link layer. The latter constructs a data frame, the destination address is the IP layer passes over the physical address, the source address is the local physical address, but also must attach some control information, according to the Ethernet media access rule, transmits them out.

Host B receives this data frame, first check its destination address, and the physical address of the machine, if the match, then receive; After receiving the data frame, the IP packet is extracted from the frame and given to the IP layer protocol of the computer. Similarly, after the IP layer check, the useful information is extracted to the ICMP protocol, the latter processing, immediately build an ICMP answer package, sent to host A, the process and host a sent ICMP request packet to Host B exactly the same.

From the working process of ping, we can know that host a received a response packet of Host B, indicating that the two host between the go, back access is normal. That is, whether from host A to Host B, or from Host B to host A, is normal. So, what causes the only one-way ping?

First, the installation of a personal firewall

In a shared-Internet machine, for security reasons, most hosts that serve as servers have personal firewall software installed, while other machines that serve as clients are not normally installed. Almost all personal firewall software, by default, does not allow other machines to ping this machine. The general approach is to filter out the ICMP request packets from the outside, but it does not impose any restrictions on the ICMP request messages that go out of the machine, and the ICMP response messages from the outside. This way, when you ping other machines from this computer, there is no problem if the network is normal. However, if you ping the machine from other machines, even if the network is all right, there will be "timeout no answer" error. Most of the single directional ping phenomenon originates from this. The solution is also very simple, according to your own use of different types of firewalls, adjust the appropriate settings can be.

Second, the wrong set IP address

Under normal circumstances, a host should have a network card, an IP address, or multiple network cards, multiple IP addresses (these addresses must be in a different IP subnet). But for the use of computers in public places, especially internet cafes, many people hand miscellaneous, which does not pan "explorer." There was a time when two computers also had this single directional ping pass, after careful examination, found that one of the computer's "Dial-up network adapter" (equivalent to a piece of soft network card) in the TCP/IP settings, set a network card IP address on the same subnet IP address, so, in the IP layer protocol appears, This host has two different interfaces in the same network segment. This problem occurs when you ping another machine from this host:

(1) The host does not know which network interface to send packets, because there are two network interfaces are connected to the same network segment;

(2) The host does not know which address to use as the source address of the packet. Therefore, from this host to Ping other machines, the IP layer protocol can not be processed, after the timeout, the ping will give a "timeout no answer" error message prompt. However, ping this host from other hosts, the request package from a specific network card, ICMP only need to simply convert the destination, the source address, and change some flags, ICMP answer packets can be successfully issued, other hosts will be able to successfully ping this machine.

Introduced here believe that you have a more detailed understanding of ping command, for ping command we commonly used to detect network signal sent and received in the LAN detection, network speed detection, 3 can also determine whether there is a network failure, For friends who often contact the network ping command is the command that you often need to use.

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.