導航:首頁 > 編程系統 > 檢測埠通不通linux

檢測埠通不通linux

發布時間:2021-03-28 17:16:55

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 ------解決的方法--------------------------------------------------------、、哦、、不是,那是看正在用的埠。。。

閱讀全文

與檢測埠通不通linux相關的資料

熱點內容
如何登錄楚雄市紀委網站 瀏覽:810
剛剛學完編程需要買什麼 瀏覽:452
c4d生長動畫教程 瀏覽:361
買魚竿是哪個網站 瀏覽:128
最好的游戲編程軟體有哪些 瀏覽:419
ovpn文件 瀏覽:699
印度發明了哪些編程語言 瀏覽:694
什麼是數據軸 瀏覽:509
知網如何檢索word格式文件 瀏覽:442
蘋果手機文件備份 瀏覽:479
小米手機鍾表app哪個好 瀏覽:356
剪切以後這個文件找不到了 瀏覽:926
創客和機器人編程哪個好 瀏覽:403
微信的聊天文件在哪裡能找到 瀏覽:146
雪佛蘭汽車編程需要的軟體有哪些 瀏覽:511
linux怎麼編譯vi文件怎麼打開 瀏覽:133
騎砍找不到配置文件 瀏覽:516
為什麼網路用語要准確 瀏覽:380
net獲取json數據 瀏覽:758
微信圖案變wechat變黑 瀏覽:530

友情鏈接