Getting a Static IP

In order to reliably access your server from the internet, you will need a static IP address. This will enable you to access your website on the same IP address even if you have to shut down / restart your virtual machine. 
In order to get a static IP address for your server please follow the steps given below:
  1. Go to the Google Cloud Platform website. 
  2. Click the hamburger menu at the top left of the screen to open up the list of services. 
  3. Navigate to VPC network under Networking and select External IP addresses from the submenu (or go to the following URL: https://console.cloud.google.com/networking/addresses)
  4. On this page, you will see the list of all static IP addresses that you have reserved. 
  5. In order to reserve a new IP address click on reserve static address in the top.
  6. A new page will open. Enter the desired name of the static IP address along with a description if you desire. 
  7. Choose a network tier. The use of a premium service tier allows the use of a network with high performance. To see the feature comparison please see this page: Network Service tiers
  8. Choose the IP version (IP4 is default and should be ok). 
  9. Choose the type of network: Best to use the Global version here. 
  10. Finally,  choose to attach the IP address to the VM (this will be the virtual machine instance which you have created previously). 
If you have not selected the option to attach the IP address to the virtual machine in the previous step then you can also add the IP address to the machine by following the next steps given below:
  1. Go to the VM instances page where VM instances are listed (https://console.cloud.google.com/compute/instances/). 
  2. Now click the name of VM instance (the name will have a small green tick in front of it if it is turned on). 
  3. Click on edit at the top of the instance details page to edit the properties of the virtual machine. 
  4. In network interfaces you will find the name of your network interface (typically this will have the name "nic0: default default". 
  5. Click the pencil icon beside the name to edit the properties. You will find that the internal IP is ephemeral (which means it changes with time) and the external IP address is also ephemeral.
  6. Click the dropdown to make it static IP and choose the IP address you have created previously.