1. 程式人生 > >用tcping檢查網站開放的埠

用tcping檢查網站開放的埠

neo之前分享過一款小巧玲瓏工具軟體:tcping,即在tcp層進行埠的ping。

tcping可以用來檢查和確認我們的網站有哪些埠是開放的,使用很順手。比如neo這幾天在研究如何關閉mysql的3306埠,就通過使用tcping工具來確認關閉埠是否成功。Linux下有有個netstat命令,總是對其輸出看得雲裡霧裡,雖然netstat -l的輸出看不到3306埠,是tcping還能ping通,而且百度雲檢測也能檢測到3306埠的開放狀態並告警。


首先下載並在合適的位置存放tcping工具,請參考:TCPING小工具的使用和下載

然後,開啟cmd視窗,使用如下命令檢查網站開放的埠:

檢查網站Web伺服器的80埠:

C:\Users\Administrator>tcping 114.215.183.12 80

Probing 114.215.183.12:80/tcp - Port is open - time=25.839ms
Probing 114.215.183.12:80/tcp - Port is open - time=16.662ms
Probing 114.215.183.12:80/tcp - Port is open - time=13.375ms
Probing 114.215.183.12:80/tcp - Port is open - time=15.192ms

Ping statistics for 114.215.183.12:80
4 probes sent.
4 successful, 0 failed.
Approximate trip times in milli-seconds:
Minimum = 13.375ms, Maximum = 25.839ms, Average = 17.767ms

C:\Users\Administrator>

80埠開啟,網站可以被訪問。

 

檢查網站資料庫伺服器的3306埠:

C:\Users\Administrator>tcping 114.215.183.12 3306

Probing 114.215.183.12:3306/tcp - Port is open - time=25.296ms
Probing 114.215.183.12:3306/tcp - Port is open - time=15.218ms
Probing 114.215.183.12:3306/tcp - Port is open - time=14.877ms
Probing 114.215.183.12:3306/tcp - Port is open - time=14.629ms

Ping statistics for 114.215.183.12:3306
4 probes sent.
4 successful, 0 failed.
Approximate trip times in milli-seconds:
Minimum = 14.629ms, Maximum = 25.296ms, Average = 17.505ms

C:\Users\Administrator>

MySQL資料庫3306埠開啟,存在安全隱患。

 

除了使用簡單,還可以看到各個埠的響應時間,這個響應時間比3層的ping的時間更精準更有參考價值。

網站響應時間可是SEO的一個重要引數哦。

 

用tcping檢視一個沒有開啟的埠:

C:\Users\Administrator>tcping 114.215.183.12 12345

Probing 114.215.183.12:12345/tcp - No response - time=2011.028ms
Probing 114.215.183.12:12345/tcp - No response - time=2001.356ms
Probing 114.215.183.12:12345/tcp - No response - time=2001.396ms
Probing 114.215.183.12:12345/tcp - No response - time=2000.701ms

Ping statistics for 114.215.183.12:12345
4 probes sent.
0 successful, 4 failed.
Was unable to connect, cannot provide trip statistics.

C:\Users\Administrator>

隨便寫一個12345埠,看到No response,就是沒有開啟的。

請同學們自己檢視一下FTP 21埠,SSH 22埠。

 

tcping有侷限性,它只能檢查tcp埠,而不能檢查udp埠。這個要注意。