Linux环境下能否知道端口的状态对于我们服务器的运维工作来讲是很重要的,接下来小编就给大家分享几种Linux环境下端口状态的判断方法。

1. nc命令
语法:nc -z -v -n IPADDRESS port
-z 仅用于端口扫描,0输入输出
-v 显示指令执行过程
-n 直接使用IP地址,而不是通过域名服务器
[root@shansibleqa ~]# nc -z -v -n IP 22
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to IP:22.
Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.
[root@shansibleqa ~]# nc -z -v -n IP 587
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to IP:587.
Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.
2. wget命令
语法:wget ip:port
如果通
[root@shansibleqa ~]# wget IP:22
--2019-12-24 17:43:50-- http://IP:22/
Connecting to IP:22... connected.
HTTP request sent, awaiting response... 200 No headers, assuming HTTP/0.9
Length: unspecified
如果不通
[root@shansibleqa ~]# wget IP:80
--2019-12-24 17:43:56-- http://IP/
Connecting to IP:80... failed: No route to host.
3. shell命令
语法:ssh -v -p port IP
能够连上
[root@shansibleqa ~]# ssh -v -p 80 XX.XX.XX.XX
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to XX.XX.XX.XX [XX.XX.XX.XX] port 80.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
连不上
[root@shansibleqa ~]# ssh -v -p 23 XX.XX.XX.XX
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to XX.XX.XX.XX [XX.XX.XX.XX] port 23.
debug1: connect to address XX.XX.XX.XX port 23: Connection timed out
ssh: connect to host XX.XX.XX.XXport 23: Connection timed out
4. curl命令
语法:curl ip:port
端口通
[root@shansibleqa ~]# curl ip:22
SSH-2.0-OpenSSH_7.4
curl: (56) Recv failure: Connection reset by peer
端口不通
[root@shansibleqa ~]# curl ip:443
curl: (52) Empty reply from server
希望南方联合小编的分享对大家有帮助,南方联合专注IDC14年,为大家提供专业化服务器托管,服务器租用,主机托管,云服务器租用,香港主机托管,云服务器租用,香港主机租用等服务器资源,详情欢迎咨询客服了解。
深圳服务器托管 深圳服务器租用 深圳主机托管 深圳主机租用 CDN加速 专线接入 独享带宽 数据中心机房机柜租用idc公司旧版网站登陆南方联合站点地图友情链接:裸金属服务器
Copyright © 2005-2020 深圳市南方联合科技有限公司 版权所有 备案号:粤ICP备05107047号 经营许可证编号:A2.B1-20170254 统一社会信用代码:91440300779894166R
售后服务技术支持
Q Q 支持:417706
电话支持:13528445704
邮箱支持:ok@souidc.com
备案专区
备案专员
备案咨询:0755-33905998