How to open a specific port such as 9090 in Google Compute Engine

前端 未结 8 1933
孤独总比滥情好
孤独总比滥情好 2020-11-22 13:15

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

相关标签:
8条回答
  • 2020-11-22 13:43

    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

    0 讨论(0)
  • 2020-11-22 13:45

    You need to:

    1. Go to cloud.google.com

    2. Go to my Console

    3. Choose your Project

    4. Choose Networking > VPC network

    5. Choose "Firewalls rules"

    6. Choose "Create Firewall Rule"

    7. 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.

    8. To allow incoming TCP connections to port 9090, in "Protocols and Ports" enter tcp:9090

    9. Click Create

    I hope this helps you.

    Update Please refer to docs to customize your rules.

    0 讨论(0)
提交回复
热议问题