Created
April 23, 2020 08:06
-
-
Save ahwayakchih/26fca8968c806cfe6e9e59617da3f1a2 to your computer and use it in GitHub Desktop.
Get IP4s of Google's servers' to, for example, whitelist them for accessing own services
This file contains 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
#!/bin/sh -e | |
get_ip4s () { | |
dig +short txt $1 | grep -Eo '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(/(3[0-2]|[1-2][0-9]|[1-9])?)?' | tr '\n' ',' | |
} | |
echo -n $(get_ip4s _netblocks.google.com) | |
# `_netblocks2.google.com` returns only IPv6 addresses, so we can skip it | |
#echo -n $(get_ip4s _netblocks2.google.com) | |
echo -n $(get_ip4s _netblocks3.google.com) | |
echo -n $(get_ip4s _netblocks4.google.com) | |
echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment