-
-
Save duckworth/64322c8f6f465629c2f6dd9273ffbc44 to your computer and use it in GitHub Desktop.
AWS Export IP Addresses
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
# Export IP addresses to support vulnerability scanning | |
# Public IPs | |
touch /tmp/public-ips.txt | |
aws ec2 describe-instances \ | |
--query "Reservations[*].Instances[*].PublicIpAddress" \ | |
--output=text \ | |
>>/tmp/public-ips.txt | |
aws ec2 describe-addresses | \ | |
jq -r .Addresses[].PublicIp \ | |
>>/tmp/public-ips.txt | |
aws elbv2 describe-load-balancers | \ | |
jq -r '.LoadBalancers[] | select(.Scheme == "internet-facing").DNSName' | \ | |
xargs -L1 -I {} sh -c "dig +short {} | head -n 1" \ | |
>>/tmp/public-ips.txt | |
cat /tmp/public-ips.txt | sort | uniq | |
# Private IPs | |
touch /tmp/private-ips.txt | |
# All IPs, including duplicates | |
# aws ec2 describe-network-interfaces | \ | |
# jq -r .NetworkInterfaces[].PrivateIpAddress \ | |
# >>/tmp/private-ips.txt | |
# EC2 server & internal load-balancer IPs | |
aws ec2 describe-instances \ | |
--query "Reservations[*].Instances[*].PrivateIpAddress" \ | |
--output=text \ | |
>>/tmp/private-ips.txt | |
aws elbv2 describe-load-balancers | \ | |
jq -r '.LoadBalancers[] | select(.Scheme == "internal").DNSName' | \ | |
xargs -L1 -I {} sh -c "dig +short {} | head -n 1" \ | |
>>/tmp/private-ips.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment