How to put a public external ip address on Google Cloud VM instance?

First attach external IP to the instance, this can be done on the console -

GCP console -> VM Instances -> "Instance Name" -> Edit -> Network Interfaces/"edit pencil" -> External IP -> Ephemeral

The external IP will not show up in the OS layer. It is a one-to-one NAT by default.

https://cloud.google.com/compute/docs/ip-addresses/reserve-static-external-ip-address#IP_assign

https://cloud.google.com/compute/docs/ip-addresses/#ephemeraladdress

Then you'll need to create firewall rules to allow traffic.

There are built in http/https tags in the VM instance to allow web traffic. Or you can create custom rules:

Navigate on the GCP console - VPC Network -> Firewall -> ...


When you create the instance you need to say to allow website traffic. On the instance creation screen/dialog you need to check the two boxes "Allow HTTP traffic" and "Allow HTTPS traffic". Then GCP will configure the firewall rules for you.

VM creation dialog

You will get an ephermeral IP when the instance is created. Then you can choose to have a static one by going to "VPC Network" -> "External IP Addresses", selecting the instance you created and changing the drop-down from Epheremal to Static.