ping命令测试网络_如何使用Ping命令测试网络

ping命令测试网络

ping命令测试网络

The ping command sends packets of data to a specific IP address on a network, and then lets you know how long it took to transmit that data and get a response. It’s a handy tool that you can use to quickly test various points of your network. Here’s how to use it.

ping命令将数据包发送到网络上的特定IP地址 ,然后让您知道传输该数据并获得响应所花费的时间。 这是一个方便的工具,可用于快速测试网络的各个点。 这是使用方法。

Ping如何工作? (How Does Ping Work?)

Ping comes from a term used in sonar technology that sends out pulses of sound, and then listens for the echo to return. On a computer network, a ping tool is built into most operating systems that works in much the same way. You issue the ping command along with a specific URL or IP address. Your computer sends several packets of information out to that device, and then waits for a response. When it gets the response, the ping tool shows you how long each packet took to make the round trip—or tells you there was no reply.

Ping来自声纳技术中使用的术语,该术语发出声音脉冲,然后侦听回声。 在计算机网络上,大多数操作系统都内置了ping工具,其工作方式几乎相同。 您发出ping命令以及特定的URL或IP地址。 您的计算机将几个信息包发送到该设备,然后等待响应。 当收到响应时,Ping工具会显示每个数据包进行往返所需的时间-或告诉您没有答复。

It sounds simple, and it is. But you can use it to good effect. You can test whether your computer can reach another device—like your router—on your local network, or whether it can reach a device on the Internet. This can help you determine if a network problem is somewhere on your local network, or somewhere beyond. The time it takes packets to return to you can help you identify a slow connection, or if you’re experiencing packet loss.

听起来很简单,确实如此。 但是您可以使用它达到良好的效果。 您可以测试计算机是否可以访问本地网络上的其他设备(例如路由器),或者可以访问Internet上的设备。 这可以帮助您确定网络问题是本地网络中的某个地方还是其他地方。 数据包返回所需的时间可以帮助您确定连接速度慢,或者遇到数据包丢失的情况。

And it pretty much doesn’t matter what operating system you’re using. Pull up a terminal or Command Prompt window, and you can use ping on macOS, Linux, or any version of Windows.

所使用的操作系统几乎无关紧要。 拉出终端或命令提示符窗口,然后可以在macOS,Linux或任何版本的Windows上使用ping。

如何使用Ping (How to Use Ping)

We’re going to use the Windows Command Prompt in our example here. But you can also use the ping command in Windows PowerShell, or in the Terminal app on macOS or any Linux distro. Once you get to using the actual command, it works the same everywhere.

在这里的示例中,我们将使用Windows命令提示符。 但是,您也可以在Windows PowerShell或macOS或任何Linux发行版的Terminal应用程序中使用ping命令。 一旦开始使用实际命令,它在任何地方都可以使用。

In Windows, hit Windows+R. In the Run window, type “cmd” into the search box, and then hit Enter.

在Windows中,按Windows + R。 在“运行”窗口中,在搜索框中键入“ cmd”,然后按Enter。

At the prompt, type “ping” along with the URL or IP address you want to ping, and then hit Enter. In the image below, we’re pinging www.howtogeek.com and getting a normal response.

在提示符下,键入“ ping”以及您要ping的URL或IP地址,然后按Enter。 在下面的图片中,我们正在对www.howtogeek.com进行ping操作,并获得正常的响应。

That response shows the URL you’re pinging, the IP address associated with that URL, and the size of the packets being sent on the first line. The next four lines show the replies from each individual packet, including the time (in milliseconds) it took for the response and the time-to-live (TTL) of the packet, which is the amount of time that must pass before the packet is discarded.

该响应显示您正在ping的URL,与该URL关联的IP地址以及在第一行发送的数据包的大小。 接下来的四行显示了来自每个单独数据包的答复,包括响应所花费的时间(以毫秒为单位)和数据包的生存时间(TTL),这是数据包在此之前必须经过的时间被丢弃。

At the bottom, you’ll see a summary that shows how many packets were sent and received, as well as the minimum, maximum, and average response time.

在底部,您将看到摘要,该摘要显示了发送和接收的数据包数量以及最小,最大和平均响应时间。

And in the next image, we’re pinging the router on our local network using its IP address. We’re also getting a normal response from it.

在下一个图像中,我们将使用其IP地址对本地网络上的路由器执行ping操作。 我们也收到了正常的回应。

When the ping tool does not get a response from whatever devices you’re pinging, it lets you know that, too.

当ping工具没有从您正在ping的任何设备获得响应时,它也会使您知道这一点。

And that’s how to use ping at its most basic. Of course, like most commands, there are some advanced switches you can use to make it behave a bit differently. For example, you can have it keep pinging a destination until you stop the command, specify the number of times you want it to ping, set how often it should ping, and more. But unless you’re doing some very specific types of troubleshooting, you won’t need to worry much about those advanced switches.

这就是使用ping最基本的方法。 当然,像大多数命令一样,您可以使用一些高级开关来使其行为有所不同。 例如,您可以让它继续对目标执行ping操作,直到停止命令,指定您要对其执行ping操作的次数,设置应该执行ping操作的频率等等。 但是,除非您要进行一些非常特定类型的故障排除,否则您不必担心这些高级开关。

If you’re curious about them, though, just type “ping /?” at the Command Prompt to see a list.

不过,如果您对它们感到好奇,只需键入“ ping /?” 在命令提示符下查看列表。

那么,您可以使用Ping做什么? (So, What Can You Do With Ping?)

Now that you know how to use the command, here are some interesting things you can do with it:

既然您已经知道如何使用该命令,则可以使用它来做一些有趣的事情:

  • Ping a URL (like www.howtogeek.com) or IP address to see if you can reach an internet destination. If you get a successful response, you know that all the networking devices between you and that destination are working, including the network adapter in your computer, your router, and whatever devices exist on the internet between your router and the destination. And if you’re interested in exploring those routes further, you can use another networking tool named tracert to do just that.

    ping URL(例如www.howtogeek.com)或IP地址,以查看是否可以到达互联网目的地。 如果您获得成功的响应,则说明您与目标之间的所有网络设备都在工作,包括计算机中的网络适配器,路由器以及路由器与目标之间的Internet上存在的任何设备。 而且,如果您有兴趣进一步探索这些路线,可以使用另一个名为tracert的网络工具来完成。

  • Ping a URL to resolve its IP address. If you want know the IP address for a particular URL, you can ping the URL. The ping tool shows you right at the top the IP address it’s working with.

    ping URL以解析其IP地址。 如果您想知道特定URL的IP地址,则可以ping URL。 ping工具会在顶部显示您正在使用的IP地址。
  • Ping your router to see if you can reach it. If you can’t successfully ping an internet location, you can then try pinging your router. A successful response lets you know that your local network is working okay, and that the problem reaching the internet location is somewhere out of your control.

    对路由器执行ping操作,以查看是否可以到达。 如果无法成功ping通Internet位置,则可以尝试ping通路由器。 成功的响应使您知道您的本地网络工作正常,并且到达Internet位置的问题不在您的控制范围之内。
  • Ping your loopback address (127.0.0.1). If you can’t successfully ping your router, but your router appears to be turned on and working, you can try pinging what’s known as a loopback address. That address is always 127.0.0.1, and pinging it successfully lets you know that the network adapter on your computer (and the networking software in your OS) is working properly.

    ping您的回送地址(127.0.0.1)。 如果您无法成功ping通路由器,但是路由器似乎已打开并且可以正常工作,则可以尝试ping通所谓的环回地址。 该地址始终为127.0.0.1,并且对其执行ping操作成功将使您知道计算机上的网络适配器(以及操作系统中的网络软件)是否正常运行。

Note: You may not get a ping response from other computers on your local network because the built-in firewalls on those devices prevent them from responding to ping requests. If you want to be able to ping those devices, you’ll need to turn off that setting to allow pings through the firewall.

注意 :您可能无法从本地网络上的其他计算机收到ping响应,因为这些设备上的内置防火墙阻止它们响应ping请求。 如果您希望能够ping通这些设备,则需要关闭该设置以允许ping通防火墙

The list above uses a kind of outside-in approach, where you ping the furthest destination first, and then work your way in to the more local devices. Some people like to work inside-out by pinging the loopback address first, then their router (or another local device), and then an internet address.

上面的列表使用了一种由外而内的方法,您可以先对最远的目的地执行ping操作,然后再进入更本地的设备。 有些人喜欢先通过ping回送地址,然后是其路由器(或其他本地设备),然后是Internet地址来进行内外工作。

And of course, what we’re talking about in this article is mostly about using ping to perform troubleshooting on a home or small business network. On larger networks, there’s a lot more complexity to worry about. Plus, if you’re tasked with troubleshooting larger networks, you probably already know how to use ping and many other networking tools.

当然,我们在本文中谈论的主要是关于使用ping在家庭或小型企业网络上执行故障排除。 在较大的网络上,有很多需要担心的复杂性。 另外,如果您要对大型网络进行故障排除,您可能已经知道如何使用ping和许多其他网络工具。

翻译自: https://www.howtogeek.com/355664/how-to-use-ping-to-test-your-network/

ping命令测试网络

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值