2012-06-30 22 views
2

我試圖通過設置一些iptables防火牆規則來提高我的服務器安全性。結果是Facebook使用Omniauth登錄停止工作。在我的日誌中,我發現Facebook至少會向我的服務器端口37035和41198發送一些軟件包。爲什麼?這些港口沒有任何東西在運行。哪些端口應該開放Facebook認證

有人可以說我應該打開哪些端口,以便Facebook使用Omniauth登錄可以在我的網站上重新開始工作。

我採用的規則是:

 
# Delete all existing rules 
iptables -X 

# Set default rules 
iptables -P INPUT DROP 
iptables -P FORWARD ACCEPT 
iptables -P OUTPUT ACCEPT 

# Allow ssh in 
iptables -A INPUT -i eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT 
iptables -A OUTPUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT 

# Allow incoming HTTP 
iptables -A INPUT -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT 
iptables -A OUTPUT -o eth0 -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT 

# Allow outgoing SSH 
iptables -A OUTPUT -o eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT 
iptables -A INPUT -i eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT 

# Allow ping from outside 
iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT 
iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT 

# Allow pingging other servers 
iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT 
iptables -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT 

# Allow loopback access 
iptables -A INPUT -i lo -j ACCEPT 
iptables -A OUTPUT -o lo -j ACCEPT 

# Allow sendmail and postfix 
iptables -A INPUT -i eth0 -p tcp --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT 
iptables -A OUTPUT -o eth0 -p tcp --sport 25 -m state --state ESTABLISHED -j ACCEPT 

# Allow dns lookups 
iptables -A OUTPUT -p udp -o eth0 --dport 53 -j ACCEPT 
iptables -A INPUT -p udp -i eth0 --sport 53 -j ACCEPT 

# Prevent dos attacks - upgrade to hashlimit if needed 
iptables -A INPUT -p tcp --dport 80 -m limit --limit 25/minute --limit-burst 100 -j ACCEPT 

# Log dropped packages 
iptables -N LOGGING 
iptables -A INPUT -j LOGGING 
iptables -A LOGGING -m limit --limit 2/min -j LOG --log-prefix "IPTables Packet Dropped: " --log-level 7 
iptables -A LOGGING -j DROP 

這是從我的系統日誌爲例日誌條目(我的IP過濾)

IPTables Packet Dropped: IN=eth0 OUT= MAC=40:40:ea:31:ac:8d:64:00:f1:cd:1f:7f:08:00 SRC=69.171.224.54 DST=my_ip LEN=56 TOS=0x00 PREC=0x00 TTL=86 ID=0 DF PROTO=TCP SPT=443 DPT=44605 WINDOW=14480 RES=0x00 ACK SYN URGP=0 
+0

我看到相同類型的流量。但是不同的端口。 'api-read-slb-10-08-prn1.facebook.com' –

+0

它在我看來,請求來到30000和60000之間的隨機端口。允許該範圍的流量固定Facebook登錄部分。它可以工作,但比所有端口打開時慢得多。 – Mika

+0

同樣的問題也可以在Google登錄中看到。我也爲我的應用添加了Google策略。這讓我懷疑這個問題來自Omniauth。 – Mika

回答