2

I am trying to turn on IP Forwarding for an interface of an instance hosted in Google Cloud.

  1. I have a f1 micro VM instance on Google Compute Engine.
  2. I've created an IP forwarding rule with gcloud succesfuly here.
    Command compute forwarding-rules describe myrulenamehere gives out description of the rule.
  3. When I open VM instance details page IP forwarding is marked as OFF and I can't change it via EDIT button.

How to turn on IP Forwarding for interface if forwarding rule was already created?

GalloCedrone
  • 371
  • 1
  • 9
ilyaigpetrov
  • 125
  • 2
  • 8

2 Answers2

3

You cannot change this value since it is a read-only value for already created instances. From the official Google documentation that you can check here:

You can only set the canIpForward field at instance creation time. After an instance is created, the field becomes read-only.

Therefore I think that the only option you have now is to create again the virtual machine, the target instance and the forwarding rule. You can enable ip-forwarding at creation time with the flag --can-ip-forward, for example:

gcloud compute instances create instance-name --can-ip-forward

You can enabling it as well from the Console, in the Network interface menu, at the creation of the instance.

You can as well keep the very same forwarding rule and update the target instance only running:

gcloud compute forwarding-rules set-target ...
GalloCedrone
  • 371
  • 1
  • 9
0

GCP has added the option to update IP_FORWARDING withouth recreating the VM instance.

gcloud compute instances update-from-file INSTANCE_NAME

For more details check update-instance-properties.

Ivan
  • 76
  • 3