Add a port forwarding rule on a specific VM instance.

0 votes
I want to add a port forwarding rule on a specific VM instance. How to do this?
Nov 11 in GCP by anonymous
• 4,330 points
30 views

1 answer to this question.

0 votes

To add a new forwarding rule, you can use the gcloud compute forwarding-rules create command or create a HTTP POST request to the Forwarding Rules collection. 

An example of creating a forwarding rule to a target instance using the gcloud command-line tool is:

gcloud compute forwarding-rules create [FORWARDING_RULE] \
    --load-balancing-scheme internal | external \
    --region [REGION] \
    [--target-instance-zone [ZONE]] \
    --ip-protocol TCP --ports 80 \
    --target-instance [TARGET_INSTANCE]

If you omit the --target-instance-zone flag, the gcloud command-line tool prompts you to choose a zone if you did not set the compute/zone property with gcloud config set compute/zone. 

The gcloud compute forwarding-rules create command supports setting a target instance as a target when the load balancing scheme is internal.

answered Nov 11 by Sirajul
• 40,980 points

Related Questions In GCP

0 votes
1 answer
0 votes
1 answer

Creating a SQL Server instance using Google Compute engine.

Google Compute Engine provides public images preconfigured with ...READ MORE

answered Sep 23 in GCP by Sirajul
• 40,980 points
53 views
0 votes
1 answer

How do i install gcloud compute?

The gcloud compute command-line tool enables you to easily ...READ MORE

answered Sep 23 in GCP by Sirajul
• 40,980 points
72 views
0 votes
1 answer
0 votes
1 answer