Debian

打開特定的 Linux 埠

  • August 22, 2014

我試圖在我的 VPS 上打開一個埠(2012),以便我可以通過網際網路訪問它。

這是sudo iptables -L的輸出

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
fail2ban-ssh  tcp  --  anywhere          anywhere             multiport dports ssh
ACCEPT     all  --  anywhere             anywhere            
REJECT     all  --  anywhere             loopback/8     reject-with icmp-port-      
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED  
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:https
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:2012
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:ssh
ACCEPT     icmp --  anywhere             anywhere            
LOG        all  --  anywhere             anywhere             limit: avg 5/min burst 5    LOG    level debug prefix "iptables denied: "
DROP       all  --  anywhere             anywhere            

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
DROP       all  --  anywhere             anywhere            

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            

Chain fail2ban-ssh (1 references)
target     prot opt source               destination         
RETURN     all  --  anywhere             anywhere  

Nmap 僅發現埠 25,22 和 80。請問我做錯了什麼?

編輯 :

netstat -anp | grep :2012顯示這個:

sudo netstat -anp | grep :2012
tcp        0      0 127.0.0.1:2012          0.0.0.0:*               LISTEN      15303/X-engine

您在埠 2012 上偵聽的服務僅在 localhost (127.0.0.1) 上偵聽。

這是不可路由的。

讓它監聽伺服器的 IPV4(或 IPV6)。

預設情況下,nmap 僅探測 1000 個最常用的埠。如果要掃描特定埠,請像這樣使用 nmap:

nmap ... -p2012 ...

引用自:https://serverfault.com/questions/623456