我在所有節點上的 iptables 中透過 kube-proxy 設定了以下鏈。
Chain KUBE-POSTROUTING (1 references)
target prot opt source destination
MASQUERADE all -- 0.0.0.0/0 0.0.0.0/0 /* kubernetes service traffic requiring SNAT */
我的所有節點都位於提供者的無狀態/靜態防火牆後面。透過以下規則設定。
tcp_established: &tcp_established
name: tcp established
ip_version: ipv4
dst_port: '32768-65535'
action: accept
protocol: tcp
tcp_flags: ack
這表示連接埠 32768-65535 TCP/ACK 上只允許來自任何地方的流量,以確保出站流量的反向連線。
在我的所有節點(Ubuntu 16.04)上設定了以下系統設定。
cat /proc/sys/net/ipv4/ip_local_port_range
32768 60999
當我嘗試透過curl和http存取遠端伺服器時,我丟失了來自低於32768的來源連接埠的連線(TCP虛假重傳)。
3 1.051525000 80→20092 [SYN, ACK] Seq=0 Ack=1 Win=64876 Len=0 MSS=1336 SACK_PERM=1 TSval=1259153497 TSecr=1768475026 WS=128 THETARGETIP THESOURCEIP TCP 74
4 2.079464000 [TCP Spurious Retransmission] 20092→80 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 SACK_PERM=1 TSval=1768476055 TSecr=0 WS=128 THESOURCEIP THETARGETIP TCP 74
有沒有辦法「告訴」iptables、kube-proxy 和/或核心使用 iptables masquarde 限制來源連接埠的範圍?
答案1
這假面舞會的文檔記錄--to-ports
選項:
--to-ports 選項用於設定要在傳出資料包上使用的一個或多個來源連接埠。 …