方法1:wget命令
1.語法
wget 192.168.1.1:8888
2.連接一個(gè)開放的端口(雖然這個(gè)端口上跑的并不是web服務(wù),但是還是會(huì)有提示)
wget 192.168.1.133:3306
--2019-06-11 15:11:40-- http://192.168.1.133:3306/
Connecting to 192.168.1.133:3306... connected.
HTTP request sent, awaiting response... 200 No headers, assuming HTTP/0.9
Length: unspecified
Saving to: ‘index.html’
[ <=> ] 113 --.-K/s in 0s
2019-06-11 15:11:40 (14.8 MB/s) - ‘index.html’ saved [113]
3.連接一個(gè)不開放的端口(提示連接拒絕)
[15:11:40 root@ntp ~ #]wget 192.168.1.133:3307
--2019-06-11 15:11:42-- http://192.168.1.133:3307/
Connecting to 192.168.1.133:3307... failed: Connection refused.
方法2:ssh 命令
1.語法
ssh -v 192.168.1.1 -p 8888
-v 顯示詳細(xì)信息
2.連接一個(gè)不開放的地址(提示連接拒絕)
## 方法1:加 -v 參數(shù)
[15:14:37 root@ntp ~ #]ssh -v 192.168.1.30 -p 3307
OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Connecting to 192.168.1.30 [192.168.1.30] port 3307.
debug1: connect to address 192.168.1.30 port 3307: Connection refused
ssh: connect to host 192.168.1.30 port 3307: Connection refused
## 方法2:不加 -v 參數(shù)(提示連接拒絕)
[15:17:04 root@ntp ~ #]ssh 192.168.1.30 -p 3307
ssh: connect to host 192.168.1.30 port 3307: Connection refused
3.連接一個(gè)開放的端口(提示)
## 方法1:加 -v 參數(shù)
[15:14:48 root@ntp ~ #]ssh -v 192.168.1.30 -p 3306
OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Connecting to 192.168.1.30 [192.168.1.30] port 3306.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type 1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: ssh_exchange_identification: N
ssh_exchange_identification: Connection closed by remote host
## 方法2:不加 -v 參數(shù)(提示連接關(guān)閉)
[15:17:02 root@ntp ~ #]ssh 192.168.1.30 -p 3306
ssh_exchange_identification: Connection closed by remote host
方法3:telnet 命令
1.語法
telnet 192.168.1.1 8888
2.連接一個(gè)開發(fā)的端口(因?yàn)檫@里測試的是一個(gè)mysql端口胞枕,所以提示的信息里有讓輸入mysqlpassword的信息)
[15:20:22 root@ntp ~ #]telnet 192.168.1.30 3306
Trying 192.168.1.30...
Connected to 192.168.1.30.
Escape character is '^]'.
N
5.7.22-log(}%LzTg???p3`>Pk4n*mysql_native_password
^CConnection closed by foreign host.
3.連接一個(gè)不開放的端口(提示連接拒絕)
[15:20:43 root@ntp ~ #]telnet 192.168.1.30 3307
Trying 192.168.1.30...
telnet: connect to address 192.168.1.30: Connection refused
方法4:nmap命令
1.語法
nmap -v 192.168.1.29 -p 3306
2.測試一個(gè)開放的端口(提示:3306/tcp open mysql)
[15:27:08 root@ntp ~ #]nmap 192.168.1.29 -p 3306
Starting Nmap 6.40 ( http://nmap.org ) at 2019-06-11 15:27 CST
Nmap scan report for 192.168.1.29
Host is up (0.00049s latency).
PORT STATE SERVICE
3306/tcp open mysql
MAC Address: 00:50:56:B0:28:4B (VMware)
Nmap done: 1 IP address (1 host up) scanned in 0.05 seconds
3.測試一個(gè)沒有開放的端口(提示:3307/tcp closed opsession-prxy)
[15:27:07 root@ntp ~ #]nmap 192.168.1.29 -p 3307
Starting Nmap 6.40 ( http://nmap.org ) at 2019-06-11 15:27 CST
Nmap scan report for 192.168.1.29
Host is up (0.00050s latency).
PORT STATE SERVICE
3307/tcp closed opsession-prxy
MAC Address: 00:50:56:B0:28:4B (VMware)
Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds