5. Networking#
This week you will take control of the networking and network security of your VM. In a way, this week’s activities are out of order. If you were going to setup a new application you would probably create the network first, then create instances. After we create a new VPC this week we’ll move our existing instance over to use it. Using a non-default VPC gives us more control over how we want to network applications. Also this week we’ll learn how to use common Linux commands to examine the state of the network, including finding the IP address and active connections to an instance.
About VPCs#
A Virtual Private Cloud (VPC) is the foundation of networking in Google Cloud. It gives your project an isolated network environment where you define subnets, assign IP ranges, and control how resources communicate with each other and with the internet. In a cloud system, the network is not just a convenience; it is the boundary that determines security, connectivity, and performance for every VM and service.
In Google Cloud, a VPC is global, but subnets are regional. This means you can design a network that matches your application’s needs while keeping traffic isolated and manageable. This week you will create a custom VPC, configure firewall rules, and move your VM onto that network so you can see how routing, security, and connectivity work together in practice.
Labs#
Use the Linux commands:
View your IP address with
ipUse
pingandtracerouteto verify network connectivityUse
netstatandssto verify connections and serversUse
curlto see your webserver
Plan IP Address Ranges#
Plan an IP address range. You should have one subnet in each of the free tier regions:
Oregon:
us-west1Iowa:
us-central1South Carolina:
us-east1
You can use IPv6 if you like but you don’t have to.
Create Firewall Rules#
The Firewall on your new VPC should enable the Internet to connect to your devbox using two protocols:
SSH (TCP/22)
HTTP (TCP/80)
Verify that you can SSH into your VM after moving it to the new VPC. After that verify that you can connect to its external IP address using your browser.
Project Documentation#
To meet the project requirements for this week you have to accomplish the following tasks:
Create a non-default VPC with custom subnets
Create firewall rules for the new VPC
Move your devbox to the new VPC
Document your progress with the following required items:
The IP address ranges you used (IPv4 is required, IPv6 is optional)
The firewall rules you applied. The list of rules must contain:
The name of the rule
Type
Target
Filters
Protocols / ports
Action
Document the steps you used to create the VPC, subnets and firewall rules. You only have to document one of the subnets and firewall rules since you will repeat the process multiple times.
Check Your Progress#
I have written a script that will help you make sure that your project is on
track so far. You can download
it to your own computer if you want to look at it but it’ll be easier to run on
Google Cloud Shell. In the cloud shell command prompt download the script with
this command:
$ wget https://www.lifealgorithmic.com/_downloads/783305960d9956b75a07490a465d551c/milestone-5-check.py
$ chmod u+x milestone-5-check.py
You just downloaded a Python executable. You can execute it like this:
$ ./milestone-5-check.py
The script will analyze your cloud resources and print out some information. It will show you an error if it finds a problem. Submit the output of this program along with the milestone documentation.