I have 2 Google Compute Engine instances and I want to open port 9090 in both the instances. I think we need to add some firewall rules.
Can you tell me how can I
Here is the command-line approach to answer this question:
gcloud compute firewall-rules create <rule-name> --allow tcp:9090 --source-tags=<list-of-your-instances-names> --source-ranges=0.0.0.0/0 --description="<your-description-here>"
This will open the port 9090
for the instances that you name. Omitting --source-tags
and --source-ranges
will apply the rule to all instances. More details are in the Gcloud documentation and the firewall-rule create command manual
The previous answers are great, but Google recommends using the newer gcloud
commands instead of the gcutil
commands.
PS:
To get an idea of Google's firewall rules, run gcloud compute firewall-rules list
and view all your firewall rules
You need to:
Go to cloud.google.com
Go to my Console
Choose your Project
Choose Networking > VPC network
Choose "Firewalls rules"
Choose "Create Firewall Rule"
To apply the rule to select VM instances, select Targets > "Specified target tags", and enter into "Target tags" the name of the tag. This tag will be used to apply the new firewall rule onto whichever instance you'd like. Then, make sure the instances have the network tag applied.
To allow incoming TCP connections to port 9090, in "Protocols and Ports" enter tcp:9090
Click Create
I hope this helps you.
Update Please refer to docs to customize your rules.