如何尋找 Amazon S3 使用的 IP 地址範圍?

1 分的閱讀內容
0

我不知道如何尋找 Amazon Simple Storage Service (Amazon S3) 使用的 IP 地址範圍。

解決方法

首先,下載包含所有 AWS IP 地址範圍的 JSON 檔案。然後,在檔案中搜尋字串 "service": "S3"

若要在 Linux 或 macOS 電腦上解析 JSON 回應,可以使用諸如 jq (來自 GitHub 網站) 的工具。例如,下列命令會解析 Amazon S3 使用的所有 IPv4 地址中的 JSON 檔案:

curl https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[] | select(.service=="S3") | .ip_prefix'

52.95.154.0/23

52.219.64.0/22

52.92.72.0/22

52.92.64.0/22

52.95.156.0/24

....

在此範例中,下列命令會解析 Amazon S3 用於 us-east-1 AWS 區域中的所有 IPv4 地址的 JSON 回應:

curl https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[] | select(.region=="us-east-1") | select(.service=="S3") | .ip_prefix'

54.231.0.0/17

52.92.16.0/20

52.216.0.0/15

在 Windows 作業系統 (OS) 上,您可以使用 AWS Tools for PowerShell。以下 Get-AWSPublicIpAddressRange 命令可篩選 Amazon S3 使用的所有 IPv4 和 IPv6 地址:


Get-AWSPublicIpAddressRange -ServiceKey S3 | select IpPrefix
IpPrefix
--------
52.47.73.72/29
13.55.255.216/29
52.15.247.208/29
...
...
2a05:d07c:2000::/40
2a05:d000:8000::/40
2406:dafe:2000::/40
...

如需更多範例,請參閱篩選 JSON 檔案

注意: 您可能會發現 JSON 檔案清單上的 IP 地址範圍與 AWS 受管字首清單之間有差異。AWS 管理 ip-ranges.json 檔案中報告的所有 IP 地址。使用 JSON 檔案手動擷取 Amazon S3 的 IP 地址範圍是最佳做法。

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