How to Block Amazon AWS Traffic Print

  • 0

Inside the Hawk Host cPanel, you can block individual IPs and ranges using our IP blocker interface. However, depending on the number of IPs, this may be time-consuming. Amazon AWS keeps a range of IPs at https://ip-ranges.amazonaws.com/ip-ranges.json, which we can parse to allow easier blocking.

The following commands can be performed on your account using SSH/Terminal.

List of IP ranges

curl -sf https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[].ip_prefix'

List of IP ranges with deny statement for .htaccess

curl -sf https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[].ip_prefix' | awk '{print "deny from " $0}'

You can also append this directly to your .htaccess file

curl -sf https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[].ip_prefix' | awk '{print "deny from " $0}' >> .htaccess

Complete Blocking by .htaccess Solution

echo "order allow,deny" >> .htaccess
echo "allow from all" >> .htaccess
curl -sf https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[].ip_prefix' | awk '{print "deny from " $0}' >> .htaccess

Remember that anytime Amazon updates its IP list, your list would now be out of date.

 


Was this answer helpful?

« Back

Ready to get started? Build your site from
$2.24/mo
GET STARTED NOW