Linux self-study journey-basic commands (network probe command-ping command)

Linux self-study journey-basic commands (ping command)


Preface

1. In the previous section, we talked about the ifconfig command we usually use to check the IP address. If you haven't read it yet, click the link below to watch it: ifconfig

2. In this section we describe another commonly used network command ping


Tip: The following is the content of this article

One, ping command format

  • Command name: ping
  • The full name of the command: send ICMP ECHO_REQUEST to network hosts
  • Location: /usr/bin/ping
  • Execution authority: all users
  • Function description: Send ICMP echo request to network host

The basic format of the command is as follows:

[root@web ~]#ping [选项] IP
常用选项:
-b:后面加入广播地址,用于对整个网段进行探测
-c 次数:用于指定ping的次数
-s 字节:指定探测包的大小

Two, ping use

1. Use ping directly

In fact, in general, in order to know whether our host can communicate with each other normally, we will directly ping + the other party’s IP. If we can return information such as ttl, time, etc., it proves that we can communicate normally. This is also The most common practice of ping.

1. As follows, I have two hosts, the IPs are 192.168.137.25 and 192.168.137.27 respectively. Now I will actually use the host 192.168.137.27 to actively ping the host .25 to see if the communication between them is reachable.
Insert picture description here

2. Ping + the IP address of the host to be communicated. If fields such as ttl and time appear, it means normal communication. If you pay attention here, if you do not actively turn off ping, this ping command will keep pinging. If you don’t ping, remember to Ctrl +C Stop it.
Insert picture description here

3. So what if I ping a host that does not exist in my LAN? Let's take a look.

4. As shown in the figure below, he will report that he cannot access the target host, because there is no such machine in my LAN at all.
Insert picture description here

2. Use ping with option

1. Didn’t I say that if you do not actively stop the ping command, it will continue to ping, but we can also use the option to make it stop automatically, that is, we can use the -c option to specify the number of times he pings .

2. As shown in the figure below, I specified ping only 3 times.
Insert picture description here

3. We can also use the -b option to specify the broadcast address of a network segment to detect the hosts that can communicate in the network segment you specify.

4. The following picture shows the hosts that can communicate in the network segment 192.168.137.0/24.
Insert picture description here


to sum up

In this section, we mainly talk about the basic usage of ping. The basic syntax is: ping + the IP of the host you want to communicate with.

This is Jiehua, see you next time!

Guess you like

Origin blog.csdn.net/qq313088385/article/details/114961381