Ping命令小结

Linux 版本:

​ VMware® Workstation 15 Pro(15.5.2 build-15785246) / Hyper-v

​ CentOS7(3.10.0-957.el7.x86_64)

Windows 版本:

​ 版本 Windows 10 教育版
​ 版本号 20H2

1.telnet 命令

$ telnet <ip_address> <port_number>

适用范围:windows(需要打开 Telnet 功能)、linux(可能需要安装:yum install telnet)

[root@node1 ~]#telnet baidu.com 80
Trying 39.156.69.79...
Connected to baidu.com.
Escape character is '^]'.
Connection closed by foreign host.

2.nc 命令

$ nc -vz <host> <port_number>

适用范围:linux

[root@node1 ~]#nc -vz 10.10.0.42 80
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connection refused.

[root@node1 ~]#nc -vz daidu.com 80
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 52.128.23.153:80.
Ncat: 0 bytes sent, 0 bytes received in 0.64 seconds.

CentOS 自带,如果需要安装:yum install netcat


3.nmap 命令

$ nmap -p <port_number> <ip_address>

适用范围:linux(yum install nmap)

[root@node1 ~]#nmap -p 1-100 192.168.16.1

Starting Nmap 6.40 ( http://nmap.org ) at 2021-04-08 19:44 CST
Nmap scan report for 192.168.16.1
Host is up (0.0016s latency).
All 100 scanned ports on 192.168.16.1 are closed
MAC Address: 00:50:56:C0:00:08 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 1.80 seconds
注意nmap可能产生法律问题

NMAP.ORG

4.PowerShell 自带命令

$ Test-NetConnection <ip_address> -p <port_number>

适用范围:windows

PS C:\Users\Aaron> Test-NetConnection 192.168.16.138 -p 80


ComputerName     : 192.168.16.138
RemoteAddress    : 192.168.16.138
RemotePort       : 80
InterfaceAlias   : VMware Network Adapter VMnet8
SourceAddress    : 192.168.16.1
TcpTestSucceeded : True

向远程主机发送“ ping”请求意味着您正在使用 ICMP 协议来检查网络连接。ICMP 主要用于诊断将阻止您访问主机的网络问题。当您 ping 端口时,实际上是在计算机和特定端口上的远程主机之间建立 TCP连接。

至于这些命令之间有何不同,有待进一步学习。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值