4
votes

Is there a network-level IP address blocking/blacklist capability to a Google Compute Engine instance? For example, a site is hosted on a GCE instance to allow public users access. However, a malicious script runs several times/second which is not legitimate traffic. Ideally, the IP of the offending user could be placed on a block list so traffic would not be routed to the instance, rather than just server side only mechanism (apache modules, IPtables, etc) which still requires CPU/RAM/disk resources.

4
Google now natively supports this with Cloud Armor. cloud.google.com/armor - TimK

4 Answers

1
votes

You can setup an HTTP load balancer for your instances, and allow traffic only from the LB IP address to your instances. More information can be found in this Help Center article.

0
votes

GCP does not provide WAF natively. You can use marketplace WAF (like Brocade WAF) to block IPs.

https://cloud.google.com/launcher/solution/brocade-public-1063/stm-csub-1000-h-saf?q=brocade

0
votes

This is absolutely not the recommended way to manage your firewall blacklist.

However...

In the compute GUI, you can create a firewall rule set action on match to "deny" and protocols and port to "deny all". Then set source IPs.

compute GUI

You could then run a cron job to update your firewall through gcloud compute firewall-rules update to update source IPs should your list change.

Note (from Google - https://cloud.google.com/vpc/docs/using-firewalls):

gcloud compute firewall-rules update is used to update firewall rules that allow/deny incoming/outgoing traffic. The firewall rule will only be updated for arguments that are specifically passed. Other attributes will remain unaffected. The action flag (whether to allow or deny matching traffic) cannot be defined when updating a firewall rule

-2
votes

Yes you can block it using Gcloud Firewall.

Try creating the firewall rule from the command line or by logging into Google Cloud.

Example:

gcloud compute firewall-rules create tcp-deny --network example-network --source-ranges 10.0.0.0/8 --allow !tcp:80

Above Rule will block the range 10.0.0.0/8 to port 80 (tcp). Same can be done to block other IP Ranges over tcp and udp.

For more info check this: glcoud network config