In the Navigation menu (Navigation menu), click Compute Engine -- VM instances.
You will see the two VM instances you created, each in a different zone.
Notice that the Internal IP addresses of these two instances share the first three bytes in common. They reside on the same subnet in their Google Cloud VPC even though they are in different zones.
To open a command prompt on the my-vm-2 instance, click SSH in its row in the VM instances list.
Use the ping command to confirm that my-vm-2 can reach my-vm-1 over the network:
ping my-vm-1.us-central1-a
Notice that the output of the ping command reveals that the complete hostname of my-vm-1 is my-vm-1.us-central1-a.c.PROJECT_ID.internal, where PROJECT_ID is the name of your Google Cloud Platform project. GCP automatically supplies Domain Name Service (DNS) resolution for the internal IP addresses of VM instances.
Press Ctrl+C to abort the ping command.
Use the ssh command to open a command prompt on my-vm-1:
ssh my-vm-1.us-central1-a
If you are prompted about whether you want to continue connecting to a host with unknown authenticity, enter yes to confirm that you do.
At the command prompt on my-vm-1, install the Nginx web server:
sudo apt-get install nginx-light -y
Use the nano text editor to add a custom message to the home page of the web server:
sudo nano /var/www/html/index.nginx-debian.html
Use the arrow keys to move the cursor to the line just below the h1 header. Add text like this, and replace YOUR_NAME with your name:
Hi from YOUR_NAME
Press Ctrl+O and then press Enter to save your edited file, and then press Ctrl+X to exit the nano text editor.
Confirm that the web server is serving your new page. At the command prompt on my-vm-1, execute this command:
curl http://localhost/
The response will be the HTML source of the web server's home page, including your line of custom text.
To exit the command prompt on my-vm-1, execute this command:
exit
You will return to the command prompt on my-vm-2
To confirm that my-vm-2 can reach the web server on my-vm-1, at the command prompt on my-vm-2, execute this command:
curl http://my-vm-1.us-central1-a/
The response will again be the HTML source of the web server's home page, including your line of custom text.
In the Navigation menu (Navigation menu), click Compute Engine --VM instances.
Copy the External IP address for my-vm-1 and paste it into the address bar of a new browser tab. You will see your web server's home page, including your custom text.