Quickstart: Create a network with a subnet and a router
Create a network with its first subnet, connect the subnet to the internet through a router with an external gateway, and delete both again.
In this quickstart, you create a network with a subnet, connect the subnet to the internet through a router, and delete both again. Instances that you later create on this network can reach the internet. The quickstart has 12 steps in three parts.
Before you begin
- You need the Owner or Contributor role on the subscription or on the project, or a custom role with Manage access to Networking.
- The subscription's quota and the project's allocation need room for one more network and one more router. See Quotas.
- For the router to get an external gateway, your project must be allowed to use an external network for Floating IPs and router gateways. The region's operator decides which external networks each project can use.
Create the network
In the console, go to NetworkingNetworks.
Select Create network.
In Network name, enter a name such as app-net. Use lowercase letters, numbers, and hyphens.
Under First subnet, keep Create a first subnet turned on. The console fills in Subnet CIDR with a private /24 block that doesn't overlap your existing subnets, names the subnet app-net-subnet-1, and shows the address that becomes the gateway under Gateway (automatic). Keep these values, or enter your own block.
Select Create network. The console opens the network's page. The network is Building and changes to Active when it's ready.
Create a router
Go to NetworkingRouters, and select Create router.
In Name, enter a name such as app-router, and select Create router. The platform gives the router an external gateway on one of the external networks that your project is allowed to use. You don't choose the network.
Open the router from the list. Its page refreshes while the router is Building.
When the router is Active, check External network and External IP on the Overview tab. If both show a dash, the router has no external gateway: select Set gateway, and confirm with Set gateway.
Attach the subnet to the router
On the router's page, select Add interface. The Interfaces tab opens with a new row.
In the Select a subnet… list, select your subnet. The list names each subnet with its network and its address block.
Select the check mark to save the row. When the interface is in place, the console shows Interface attached, and the interface appears in the list.
Verify
On the router's page, select the Route table tab. The table lists a route for your subnet's address block with the origin Connected, and a route for 0.0.0.0/0 with the origin Default gateway.
To confirm the path from an instance, create an instance on the network, open its Networking tab, and read the Internet access check panel. See Check a virtual machine's internet access.
Clean up resources
Delete the router first. A network whose subnet is still attached to a router can't be deleted.
On the router's page, select Delete, and confirm with Delete router. The console clears the external gateway, detaches the interfaces, and then deletes the router.
On the network's page, select Delete, and confirm with Delete network. The subnet is deleted with the network.
Next steps
Manage networks and subnets
Add subnets, and change DNS servers and host routes.
Manage routers and static routes
Attach more subnets, and add static routes.
Internet access: SNAT and Floating IPs
How instances reach the internet, and how the internet reaches them.
Quickstart: Create a Linux virtual machine
Create an instance on your network and sign in over SSH.