1. linux下如何測試一個IP地址的某個埠通不通
在確定防火牆和selinux已經關閉的情況下,使用命令:telnet ip 埠
如果埠不通會有提示
2. 兩台linux伺服器埠不通怎麼解決
准備環境
啟動一個web伺服器,提供埠.
?
1
2
[wyq@localhost ~]$ python -m SimpleHTTPServer 8080
Serving HTTP on 0.0.0.0 port 8080 ...
用其它web伺服器提供埠也一樣,由於python比較方便,這里就用它
1、使用telnet判斷
telnet是windows標准服務,可以直接用;如果是linux機器,需要安裝telnet.
用法: telnet ip port
1)先用telnet連接不存在的埠
?
1
2
3
[root@localhost ~]# telnet 10.0.250.3 80
Trying 10.0.250.3...
telnet: connect to address 10.0.250.3: Connection refused #直接提示連接被拒絕
2)再連接存在的埠
?
1
2
3
4
5
6
7
8
[root@localhost ~]# telnet localhost 22
Trying ::1...
Connected to localhost. #看到Connected就連接成功了
Escape character is '^]'.
SSH-2.0-OpenSSH_5.3
a
Protocol mismatch.
Connection closed by foreign host.
2、使用ssh判斷
ssh是linux的標准配置並且最常用,可以用來判斷埠嗎?
用法: ssh -v -p port username@ip
-v 調試模式(會列印日誌).
-p 指定埠
username可以隨意
1)連接不存在埠
?
1
2
3
4
5
6
7
8
9
[root@localhost ~]# ssh 10.0.250.3 -p 80
ssh: connect to host 10.0.250.3 port 80: Connection refused
[root@localhost ~]# ssh 10.0.250.3 -p 80 -v
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 10.0.250.3 [10.0.250.3] port 80.
debug1: connect to address 10.0.250.3 port 80: Connection refused
ssh: connect to host 10.0.250.3 port 80: Connection refused
2)連接存在的埠
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[root@localhost ~]# ssh ... -p
a
^]
^C
[root@localhost ~]# ssh ... -p -v
OpenSSH_.p, OpenSSL ..e-fips Feb
debug: Reading configuration data /etc/ssh/ssh_config
debug: Applying options for *
debug: Connecting to ... [...] port .
debug: Connection established.
debug: permanently_set_uid: /
debug: identity file /root/.ssh/identity type -
debug: identity file /root/.ssh/identity-cert type -
debug: identity file /root/.ssh/id_rsa type -
debug: identity file /root/.ssh/id_rsa-cert type -
debug: identity file /root/.ssh/id_dsa type -
debug: identity file /root/.ssh/id_dsa-cert type -
a
^C
不用-v選項也可以咯
3、使用wget判斷
wget是linux下的下載工具,需要先安裝.
用法: wget ip:port
1)連接不存在的埠
?
1
2
3
[root@localhost ~]# wget ...:
---- ::-- http://.../
Connecting to ...:... failed: Connection refused.
2)連接存在的埠
?
1
2
3
4
[root@localhost ~]# wget ...:
---- ::-- http://...:/
Connecting to ...:... connected.
HTTP request sent, awaiting response...
4、使用埠掃描工具
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[root@localhost ~]# nmap ... -p
Starting Nmap . ( http://nmap.org ) at -- : CST
Nmap scan report for ...
Host is up (.s latency).
PORT STATE SERVICE
/tcp closed http
MAC Address: B:A::CF:FD:D (Unknown)
Nmap done: IP address ( host up) scanned in . seconds
[root@localhost ~]# nmap ... -p
Starting Nmap . ( http://nmap.org ) at -- : CST
Nmap scan report for ...
Host is up (.s latency).
PORT STATE SERVICE
/tcp open http-proxy
MAC Address: B:A::CF:FD:D (Unknown)
Nmap done: IP address ( host up) scanned in . seconds
[root@localhost ~]# nmap ...
Starting Nmap . ( http://nmap.org ) at -- : CST
Nmap scan report for ...
Host is up (.s latency).
Not shown: closed ports
PORT STATE SERVICE
/tcp open ssh
/tcp open rpcbind
/tcp open http-proxy
/tcp open unknown
MAC Address: B:A::CF:FD:D (Unknown)
Nmap done: IP address ( host up) scanned in . seconds
總結
提供埠服務,則使用了tcp協議,上面是以web伺服器為例。如果伺服器是更簡單的tcp伺服器,三個工具同樣適用.
三個工具的共同點是:1.以tcp協議為基礎;2.能訪問指定埠. 遵循這兩點可以找到很多工具.
一般在windows下使用telnet比較方便,linux下個人就比較喜歡用wget.
3. Linux下怎樣查看某一埠是否開放
可以用nmap工具進行檢測埠是否開放。
1:nmap工具檢測開放埠
nmap是一個網路連接端掃描軟體,用來掃描網上電腦開放的網路連接端。確定哪些服務運行在哪些連接端,並且推斷計算機運行哪個操作系統(這是亦稱 fingerprinting)。它是網路管理員必用的軟體之一,以及用以評估網路系統安全。
正如大多數被用於網路安全的工具,nmap 也是不少黑客及駭客(又稱腳本小子)愛用的工具 。系統管理員可以利用nmap來探測工作環境中未經批准使用的伺服器,但是黑客會利用nmap來搜集目標電腦的網路設定,從而計劃攻擊的方法。
Nmap 常被跟評估系統漏洞軟體Nessus混為一談。Nmap 以隱秘的手法,避開闖入檢測系統的監視,並盡可能不影響目標系統的日常操作。
4. 判斷埠通不通的幾種方法
1、使用telnet判斷
telnet是windows標准服務,可以直接用;如果是linux機器,需要安裝telnet.
用法: telnet ip port
1)先用telnet連接不存在的埠
[root@localhost ~]# telnet 10.0.250.3 80
Trying 10.0.250.3...
telnet: connect to address 10.0.250.3: Connection refused #直接提示連接被拒絕
2)再連接存在的埠
[root@localhost ~]# telnet localhost 22
Trying ::1...
Connected to localhost. #看到Connected就連接成功了
Escape character is '^]'.
SSH-2.0-OpenSSH_5.3
a
Protocol mismatch.
Connection closed by foreign host.
2、使用ssh判斷
ssh是linux的標准配置並且最常用,可以用來判斷埠嗎?
用法: ssh -v -p port username@ip
-v 調試模式(會列印日誌).
-p 指定埠
username可以隨意
1)連接不存在埠
[root@localhost ~]# ssh 10.0.250.3 -p 80
ssh: connect to host 10.0.250.3 port 80: Connection refused
[root@localhost ~]# ssh 10.0.250.3 -p 80 -v
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 10.0.250.3 [10.0.250.3] port 80.
debug1: connect to address 10.0.250.3 port 80: Connection refused
ssh: connect to host 10.0.250.3 port 80: Connection refused
2)連接存在的埠
[root@localhost ~]# ssh ... -p
a
^]
^C
[root@localhost ~]# ssh ... -p -v
OpenSSH_.p, OpenSSL ..e-fips Feb
debug: Reading configuration data /etc/ssh/ssh_config
debug: Applying options for *
debug: Connecting to ... [...] port .
debug: Connection established.
debug: permanently_set_uid: /
debug: identity file /root/.ssh/identity type -
debug: identity file /root/.ssh/identity-cert type -
debug: identity file /root/.ssh/id_rsa type -
debug: identity file /root/.ssh/id_rsa-cert type -
debug: identity file /root/.ssh/id_dsa type -
debug: identity file /root/.ssh/id_dsa-cert type -
a
^C
不用-v選項也可以咯
3、使用wget判斷
wget是linux下的下載工具,需要先安裝.
用法: wget ip:port
1)連接不存在的埠
[root@localhost ~]# wget ...:
---- ::-- http://.../
Connecting to ...:... failed: Connection refused.
2)連接存在的埠
[root@localhost ~]# wget ...:
---- ::-- http://...:/
Connecting to ...:... connected.
HTTP request sent, awaiting response...
5. Linux下,不用telnet命令,還有別的命令可以測試埠是否開放嗎
可以用python的socket模塊,比telnet快多了。下面是我測試過的代碼,樓主可以參考一下:
#!/usr/local/bin/python
#nameIsOpen.py
importos
importsys
importsocket
#firstargument
host=sys.argv[1]
#secondargument
port=int(sys.argv[2])
#sockettryconnect
defIsOpen(ip,port):
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
try:
s.connect((ip,port))
s.shutdown(2)
print('IP%s,port%disopen'%(ip,port))
returnTrue
except:
print('IP%s,port%disdown'%(ip,port))
returnFalse
if__name__=='__main__':
6. 如何測試埠通不通
1、使用telnet判斷
telnet是windows標准服務,可以直接用;如果是linux機器,需要安裝telnet.
用法: telnet ip port
1)先用telnet連接不存在的埠
[root@localhost ~]# telnet 10.0.250.3 80
Trying 10.0.250.3...
telnet: connect to address 10.0.250.3: Connection refused #直接提示連接被拒絕
2)再連接存在的埠
[root@localhost ~]# telnet localhost 22
Trying ::1...
Connected to localhost. #看到Connected就連接成功了
Escape character is '^]'.
SSH-2.0-OpenSSH_5.3
a
Protocol mismatch.
Connection closed by foreign host.
2、使用ssh判斷
ssh是linux的標准配置並且最常用,可以用來判斷埠嗎?
用法: ssh -v -p port username@ip
-v 調試模式(會列印日誌).
-p 指定埠
username可以隨意
1)連接不存在埠
[root@localhost ~]# ssh 10.0.250.3 -p 80
ssh: connect to host 10.0.250.3 port 80: Connection refused
[root@localhost ~]# ssh 10.0.250.3 -p 80 -v
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 10.0.250.3 [10.0.250.3] port 80.
debug1: connect to address 10.0.250.3 port 80: Connection refused
ssh: connect to host 10.0.250.3 port 80: Connection refused
2)連接存在的埠
[root@localhost ~]# ssh ... -p
a
^]
^C
[root@localhost ~]# ssh ... -p -v
OpenSSH_.p, OpenSSL ..e-fips Feb
debug: Reading configuration data /etc/ssh/ssh_config
debug: Applying options for *
debug: Connecting to ... [...] port .
debug: Connection established.
debug: permanently_set_uid: /
debug: identity file /root/.ssh/identity type -
debug: identity file /root/.ssh/identity-cert type -
debug: identity file /root/.ssh/id_rsa type -
debug: identity file /root/.ssh/id_rsa-cert type -
debug: identity file /root/.ssh/id_dsa type -
debug: identity file /root/.ssh/id_dsa-cert type -
a
^C
不用-v選項也可以咯
3、使用wget判斷
wget是linux下的下載工具,需要先安裝.
用法: wget ip:port
1)連接不存在的埠
[root@localhost ~]# wget ...:
---- ::-- http://.../
Connecting to ...:... failed: Connection refused.
2)連接存在的埠
[root@localhost ~]# wget ...:
---- ::-- http://...:/
Connecting to ...:... connected.
HTTP request sent, awaiting response...
7. Linux系統下怎麼測試埠的連通性
可以使用nc命令測試。
例如測試一下 某個個IP 的80 埠有沒有開啟可以內使用命令:容nc -z -w 1 「IP地址」 80
8. linux檢測埠通不通
ping能檢查IP檢查埠啊 ------解決--------------------------------------------------------TCP telnet 102.106.228.173 8601即 ------解決--------------------------------------------------------探討引用: TCP telnet 102.106.228.173 8601即沒命令啊------解決--------------------------------------------------------探討引用:引用:TCP ------解決--------------------------------------------------------沒裝telnet 客戶端 ------解決-------------------------------------------------------- = = 嘗試用c語言寫程序建立鏈接看 nmap些工具 ------解決--------------------------------------------------------netstat -an grep 8601 ------解決--------------------------------------------------------、、哦、、看用埠
9. linux下怎麼測試一個IP地址的某個埠通不通
ping只能檢查IP,無法檢查埠啊 ------解決的方法--------------------------------------------------------如果是TCP的 telnet 102.106.228.173 8601即可 ------解決的方法--------------------------------------------------------探討引用: 如果是TCP的 telnet 102.106.228.173 8601即可沒這命令啊------解決的方法--------------------------------------------------------探討引用:引用:如果是TCP的 ------解決的方法--------------------------------------------------------沒有就裝一個telnet 客戶端就可以了 ------解決的方法-------------------------------------------------------- = =! 可以嘗試用c語言寫一個小程序建立鏈接看可以不 還有nmap這些工具了 ------解決的方法--------------------------------------------------------netstat -an | grep 8601 ------解決的方法--------------------------------------------------------、、哦、、不是,那是看正在用的埠。。。