如何解決 Amazon VPC 中 NAT 閘道的 "ErrorPortAllocation" 錯誤?

2 分的閱讀內容
0

我想解決 Amazon Virtual Private Cloud (Amazon VPC) 上網路位址轉譯 (NAT) 閘道的 "ErrorPortAllocation" 錯誤。

簡短描述

NAT 閘道最多可支援 55,000 個同時連線至每個目的地。當超過此閾值時,與目的地的新連線會失敗,且 Amazon CloudWatch 中 NAT 閘道的 ErrorPortAllocation 指標會增加。

在您開始解決 ErrorPortAllocation 錯誤之前,請完成下列任務:

  • 確定 VPC 流程日誌已在 Amazon VPC 層級或使用 NAT 閘道的子網路啟用。
  • 確定已將 VPC 流程日誌設定為傳遞到 CloudWatch。

若要解決 ErrorPortAllocation 錯誤,請完成下列步驟:

  1. 找到來源用戶端及其連線目的地。
  2. 使用最佳實務解決連接埠配置錯誤

解決方法

找到來源用戶端及其連線目的地

1.    開啟 CloudWatch 主控台

2.    在導覽窗格中,選擇 Insights

3.    對於日誌群組,請選擇要記錄流程日誌的日誌群組。

4.    在您收到連接埠配置錯誤的時段內,識別回應數量最多的流量目的地 IP 地址:

注意:將您要尋找流量目的地的 NAT 閘道的私有 IP 地址取代example-NAT-gateway-private-IP。將 Amazon VPC CIDR 範圍的前兩個八位元組取代 example-y.y

filter (srcAddr like example-NAT-gateway-private-IP and dstAddr not like example-y.y)
| stats count(*) as numaccept by dstAddr
| sort numaccept desc
| limit 10

5.    識別傳送流量到目的地 IP 地址的來源用戶端:

注意:將步驟 4 中的前置目的地 IP 地址取代 example-destination-IP。將 Amazon VPC CIDR 範圍的前兩個八位元組取代 example-y.y

filter (dstAddr like example-destination-IP and srcAddr like example-y.y)
| stats sum(bytes) as bytesTransferred by srcAddr, dstAddr
| sort bytesTransferred desc
| limit 10

使用最佳實務解決連接埠配置錯誤

若要解決連接埠配置錯誤,請使用下列最佳實務:

  • 建立次要 IPv4 地址關聯,以增加可用連接埠數量,並增加工作負載可建立的並行連線限制。最多可將八個 IPv4 地址與您的 NAT 閘道建立關聯 (1 個主要 IPv4 地址和 7 個次要 IPv4 地址)。
  • 在每個可用區域中建立 NAT 閘道,並跨多個可用區域分配用戶端。使用 NAT 閘道路由與用戶端相同的可用區域中的流量。這有助於降低跨可用區域資料費用。
  • 如果 CloudWatch 中的 IdleTimeoutCount 指標有所增加,則請設定您的應用程式或私有執行個體關閉閒置連線。這可讓 NAT 閘道將來源連接埠配置給新連線。
  • 限制您的用戶端可以連線到單一目的地的數量。
  • 如果流量周遊至相同 AWS 區域中的 Amazon Simple Storage Service (Amazon S3) 或 Amazon DynamoDB 公有 IP 地址,請使用閘道端點。當您使用閘道 Amazon VPC 端點時,不會收取資料費用。

相關資訊

範例查詢

使用 Amazon CloudWatch 監控 NAT 閘道

編輯次要 IP 地址關聯

AWS 官方
AWS 官方已更新 5 個月前