Devops/AWS

[AWS] AWS IP λŒ€μ—­ ν™•μΈν•˜λŠ” 방법

yuri lee 2023. 2. 2. 21:48
λ°˜μ‘ν˜•

Intro

μ•ˆλ…•ν•˜μ„Έμš”. 이번 μ‹œκ°„μ—λŠ” AWS IP λŒ€μ—­μ„ ν™•μΈν•˜λŠ” 방법에 λŒ€ν•΄ μ•Œμ•„λ³΄λ„λ‘ ν•˜κ² μŠ΅λ‹ˆλ‹€. 

 

AWS IP λŒ€μ—­

AWS λŠ” IP λŒ€μ—­μ„ json ν˜•νƒœλ‘œ μ œκ³΅ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. (https://ip-ranges.amazonaws.com/ip-ranges.json)

{
  "syncToken": "1675316588",
  "createDate": "2023-02-02-05-43-08",
  "prefixes": [
    {
      "ip_prefix": "3.2.34.0/26",
      "region": "af-south-1",
      "service": "AMAZON",
      "network_border_group": "af-south-1"
    },
    {
      "ip_prefix": "3.5.140.0/22",
      "region": "ap-northeast-2",
      "service": "AMAZON",
      "network_border_group": "ap-northeast-2"
    },
    {
      "ip_prefix": "13.34.37.64/27",
      "region": "ap-southeast-4",
      "service": "AMAZON",
      "network_border_group": "ap-southeast-4"
    },
    ...
}

 

Seoul Region AWS

ν•˜μ§€λ§Œ ν•΄λ‹Ή jsonμ—λŠ” 맀우 λ§Žμ€ region IPκ°€ μ‘΄μž¬ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. 이 μ€‘μ—μ„œ μ„œμšΈ λ¦¬μ „μ˜ EC2 IP λŒ€μ—­μ„ μΆ”μΆœν•˜κ³  싢을 λ•ŒλŠ” μ•„λž˜μ˜ λͺ…λ Ήμ–΄λ₯Ό μ‚¬μš©ν•˜λ©΄ λ©λ‹ˆλ‹€ .

➜  ~ curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[] | select(.region=="ap-northeast-2") | select(.service=="EC2") | .ip_prefix'
3.5.140.0/22
151.148.40.0/24
15.177.76.0/24
43.200.0.0/14
3.36.0.0/14
3.2.37.0/26
54.180.0.0/15
52.79.0.0/16
13.125.0.0/16
15.193.9.0/24
35.71.109.0/24
52.94.248.176/28
13.124.0.0/16
99.77.141.0/24
3.5.144.0/23
13.209.0.0/16
52.78.0.0/16
99.77.242.0/24
99.150.24.0/21
52.95.252.0/24
15.164.0.0/15
3.34.0.0/15
99.151.144.0/21

 


https://slog2.tistory.com/23

λ°˜μ‘ν˜•