Created
November 28, 2019 11:01
-
-
Save embarq/127d94882f0647449a4802ee2906d639 to your computer and use it in GitHub Desktop.
GCloud Compute Engine: add multiple firewall rules for desired TCP ports
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/bash | |
BASE_RULE_NAME="rule-allow-tcp" | |
TARGET_NET_TAG="frontserver" # For more info see https://cloud.google.com/vpc/docs/add-remove-network-tags | |
for PORT in 4201 4202 4203 4204 4205 4206 4207 4208 4209 | |
do | |
# See reference https://cloud.google.com/vpc/docs/using-firewalls | |
gcloud compute firewall-rules create $BASE_RULE_NAME-$PORT \ | |
--source-ranges 0.0.0.0/0 \ | |
--allow tcp:$PORT \ | |
--target-tags=$TARGET_NET_TAG | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment