189 8069 5689

总结几种Linux环境下端口状态判断的方法-创新互联

1. nc命令
语法:nc -z -v -n IPADDRESS port
-z 仅用于端口扫描,0输入输出
-v 显示指令执行过程
-n 直接使用IP地址,而不是通过域名服务器

创新互联公司主要从事成都网站建设、网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务廊坊,十多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18982081108
[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

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


本文名称:总结几种Linux环境下端口状态判断的方法-创新互联
分享路径:http://cdxtjz.com/article/pccjc.html

其他资讯