Created
January 15, 2025 15:22
-
-
Save nobiit/e7ce4cdd65a73ebbd98725efe25313e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| ip_ranges="$(curl -fsL https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes')" | |
| python3 - "${1}" <<-EOF | |
| from sys import stdin, argv | |
| from ipaddress import ip_address, ip_network | |
| for network in $(echo "${ip_ranges}" | jq -r 'tojson'): | |
| if ip_address(argv[1]) in ip_network(network["ip_prefix"]): | |
| print(network) | |
| EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment