通常我們會用 ping 這個指令來確認對方主機的狀態,但是要確定對方主機某一個埠 TCP port 是否有開啟,那還是一樣可以用 ping 的嗎?? 答案是不行的因為 Ping 使用了 ICMP ( Internet Control Message Protocol)
ICMP 的全名是 Internet Control Message Protocol, ICMP 主要是一個 錯誤偵測與回報機制的協定,而 ICMP 跟 IP 一樣在 TCP/IP 7 layer 的第三層 網路層 (Network) .而 TCP 是 IP 的上一層,才有 Port 埠的定義.所以我們無法透過 ICMP 得知,某 TCP Port 是否開啟.
那有其他方式嗎?? 有的,下面幾種方式.
Windows:
- PaPing:http://code.google.com/p/paping
C:\Users\Ben\Desktop>paping www.google.com -p 80 -c 4 paping v1.5.5 - Copyright (c) 2011 Mike Lovell Connecting to www.google.com on TCP 80: Connected to 173.194.72.103: time=165.52ms protocol=TCP port=80 Connected to 173.194.72.103: time=213.53ms protocol=TCP port=80 Connected to 173.194.72.103: time=71.51ms protocol=TCP port=80 Connected to 173.194.72.103: time=139.52ms protocol=TCP port=80 Connection statistics: Attempted = 4, Connected = 4, Failed = 0 (0.00%) Approximate connection times: Minimum = 71.51ms, Maximum = 213.53ms, Average = 147.52ms
Linux:
- PaPing:http://code.google.com/p/paping
#paping www.google.com -p 80 -c 4
- nc (或是 netcat)
#nc -vz google.com 80
- hping
#hping google.com -S -V -p 80
- nmap
#nmap -p 80 google.com
其他參數使用請參考 https://benjr.tw/28087
- Telnet
不過最奇特的是可以使用 telnet 來試驗.benteki-air:~ ben$ telnet www.google.com 23 Trying 74.125.203.99... ^C
沒開 port 23 (telnet)
benteki-air:~ ben$ telnet www.google.com 80 Trying 74.125.23.147... Connected to www.google.com. Escape character is '^]'. ^C^C^] telnet> quit Connection closed. benteki-air:~ ben$ telnet www.google.com 443 Trying 74.125.23.103... Connected to www.google.com. Escape character is '^]'. ^]
TCP Port 80(HTTP),443(HTTPS) 都有開.
沒有解決問題,試試搜尋本站其他內容
還不錯的介紹。