ping命令的使用可用來(lái)進(jìn)行網(wǎng)絡(luò)連接測(cè)試的一個(gè)程序,Ping命令其實(shí)是一個(gè)非常好用的網(wǎng)絡(luò)故障診斷工具,其對(duì)應(yīng)的文件名為“ping.exe”。根據(jù)不同的測(cè)試目的,此命令可帶上不同的參數(shù)。下面小編教你win10如何使用ping命令。
1、在windows里點(diǎn)擊打開windows命令處理程序,或者直接運(yùn)行里輸入cmd
2、最簡(jiǎn)單常用的就是ping目標(biāo)地址,是域名或者ip都可以
3、cmd下我們要查看ping命令的參數(shù)可以在ping后面+/?
4、ping -t ip或域名,-t也可以放在最后面,表示常ping,我們?cè)谡{(diào)試網(wǎng)絡(luò)中經(jīng)常使用,還有測(cè)試丟包率
5、ping -n 是表示次數(shù),就是測(cè)試幾次,如果需要ping測(cè)100次,就在-n后面寫上100即可
6、一般默認(rèn)字節(jié)數(shù)是32,有時(shí)我們需要測(cè)試大包,比如1000,3000,我們寫上-l 然后寫上數(shù)字代表測(cè)試大包字節(jié)數(shù)
以上就是使用ping命令的方法。
在Windows系統(tǒng)中,有一個(gè)叫hosts的系統(tǒng)文件,可以用它進(jìn)行本地IP地址映射,文件的原始內(nèi)容如下:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
設(shè)置本地IP地址映射后,可以簡(jiǎn)化一些操作,比如ping命令,ssh命令。這個(gè)特點(diǎn)對(duì)于做編程或網(wǎng)路的場(chǎng)景比較實(shí)用。比如,開發(fā)人員可能在自己的電腦上部署幾臺(tái)虛擬機(jī)作為測(cè)試環(huán)境,經(jīng)常需要用ssh命令連接虛擬機(jī)或者使用ping命令測(cè)試網(wǎng)絡(luò)測(cè)試虛擬機(jī)的網(wǎng)絡(luò)情況。我的頻道會(huì)及時(shí)的整理出windows操作的技巧和實(shí)用方法,喜歡的朋友可以關(guān)注,點(diǎn)贊,收藏,分享給朋友。
在Win11系統(tǒng)中,映射文件的位置在C:\Windows\System32\drivers\etc目錄下,其它Windows系統(tǒng)的位置可能會(huì)略有不同。
1. 在文件的最后加入,每個(gè)映射關(guān)系占一行。
2. IP地址在前面,后面是機(jī)器名,IP地址和機(jī)器名之間最少要有一個(gè)空格。
3. `#` 號(hào)后面的內(nèi)容是注釋,可以獨(dú)占一行,也可以跟在設(shè)置的后面。
4. hosts屬于系統(tǒng)文件,修改時(shí),需要使用管理員權(quán)限才能保存。
5. 保存完成后即刻生效。
IP地址 映射字符串
例如,我給自己的電腦上加入一條設(shè)置`192.168.100.71 combo71`,就是將192.168.100.71這個(gè)地址與combo71這個(gè)字符串建立了對(duì)應(yīng)關(guān)系,當(dāng)然,為了實(shí)用考慮,這個(gè)字符串一般是局域網(wǎng)內(nèi)某臺(tái)機(jī)器的機(jī)器名或是域名。修改后的hosts文件如下:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
# 虛擬機(jī)上的機(jī)器
192.168.100.71 combo71
設(shè)置成功后 ping 192.168.100.71的效果和ping combo71對(duì) 效果是一樣的。如下:
C:\Users\80771>ping 192.168.100.71
正在 Ping 192.168.100.71 具有 32 字節(jié)的數(shù)據(jù):
來(lái)自 192.168.100.71 的回復(fù): 字節(jié)=32 時(shí)間<1ms TTL=64
來(lái)自 192.168.100.71 的回復(fù): 字節(jié)=32 時(shí)間<1ms TTL=64
來(lái)自 192.168.100.71 的回復(fù): 字節(jié)=32 時(shí)間<1ms TTL=64
來(lái)自 192.168.100.71 的回復(fù): 字節(jié)=32 時(shí)間<1ms TTL=64
192.168.100.71 的 Ping 統(tǒng)計(jì)信息:
數(shù)據(jù)包: 已發(fā)送 = 4,已接收 = 4,丟失 = 0 (0% 丟失),
往返行程的估計(jì)時(shí)間(以毫秒為單位):
最短 = 0ms,最長(zhǎng) = 0ms,平均 = 0ms
C:\Users\80771>ping combo71
正在 Ping combo71 [192.168.100.71] 具有 32 字節(jié)的數(shù)據(jù):
來(lái)自 192.168.100.71 的回復(fù): 字節(jié)=32 時(shí)間<1ms TTL=64
來(lái)自 192.168.100.71 的回復(fù): 字節(jié)=32 時(shí)間<1ms TTL=64
來(lái)自 192.168.100.71 的回復(fù): 字節(jié)=32 時(shí)間<1ms TTL=64
來(lái)自 192.168.100.71 的回復(fù): 字節(jié)=32 時(shí)間<1ms TTL=64
192.168.100.71 的 Ping 統(tǒng)計(jì)信息:
數(shù)據(jù)包: 已發(fā)送 = 4,已接收 = 4,丟失 = 0 (0% 丟失),
往返行程的估計(jì)時(shí)間(以毫秒為單位):
最短 = 0ms,最長(zhǎng) = 0ms,平均 = 0ms
感謝閱讀到最后,關(guān)注我,持續(xù)給您帶來(lái)簡(jiǎn)單,實(shí)用的Windows操作技巧。