
我正在為這個問題撓頭……我正在使用 Shields Up,同時代理到我剛剛使用 Rackspace 設定的伺服器。這是我的 iptables 設定:
*filter
# Allow all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT
# Accept all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow all outbound traffic - you can modify this to only allow certain traffic
-A OUTPUT -j ACCEPT
# Allow HTTP and HTTPS connections from anywhere (the normal ports for websites and SSL).
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT
# Allow SSH connections
-A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT
# Allow ping
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
# Reject all other inbound - default deny unless explicitly allowed policy
-A INPUT -j REJECT
-A FORWARD -j REJECT
COMMIT
我已將其保存到設定檔中並使用 iptables-restore 加載它。這是我的連接埠掃描的樣子:
什麼可能導致這種關閉連接埠的模式?
編輯: iptables -L 的輸出
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
REJECT all -- anywhere 127.0.0.0/8 reject-with icmp-port-unreachable
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 state NEW tcp dpt:ssh
ACCEPT icmp -- anywhere anywhere icmp echo-request
REJECT all -- anywhere anywhere reject-with icmp-port-unreachable
Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- anywhere anywhere reject-with icmp-port-unreachable
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
答案1
什麼可能導致這種關閉連接埠的模式?
一個蹩腳的掃描器。您正在新增一個
-A INPUT -j REJECT
規則將導致您的主機回應ICMP type 3 / code 3
訊息(目的地無法到達 - 連接埠無法到達)對於除先前接受的連接埠 22、80 和 443 之外的所有連接埠(後者也不會出現在掃描中)。無論如何,這不應該導致“隱形”連接埠。
吉布森不可信和其他人對臭名昭著的事件也做出了類似的觀察“護盾升起!” 幾年前:
GRC「奈米探針」努力連接()到伺服器,然後繼續徘徊。然而,連接埠測試告訴我我的 HTTP 連接埠已關閉。奇怪的。很奇怪。查看我從該連接嗅探的日誌顯示我的網站伺服器已回應 - 測試程式仍然報告它已關閉。我在基於 Windows 和 Unix 的 Web 伺服器上重複了這個練習,得到的總體命中率低於 30%,換句話說,測試程式通常不會偵測到我的開放 Web 伺服器。
看來,有些事情永遠不會改變。
作為替代方案,恢復使用公開可用的開源工具。地圖是一款通用掃描儀,您幾乎可以透過每月 5 美元的 VPS 主機上的任何發行版獲得。如果您只需要偶爾掃描,您可以使用線上 nmap 服務,例如在線域名工具中的一個。