Manage networks and subnets
Create, rename, and delete networks, and add, edit, and delete subnets with their gateway, DHCP, DNS servers, host routes, and allocation pools.
Create a network with its first subnet, add more subnets, change their settings, and delete networks and subnets that you no longer need. For how networks and subnets work, see Subnets, routers, and routes.
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. To view networks, any role with Read access to Networking is enough.
- Networks and subnets count against the subscription's quota and the project's allocation. See Quotas.
Create a network
In the console, go to NetworkingNetworks, and select Create network.
In Network name, enter a name.
Optional: in DNS servers, enter the DNS servers for the network's subnets.
Under First subnet, keep Create a first subnet turned on. Keep the suggested Subnet CIDR and Subnet name, or enter your own.
Optional: under Tags, add key-value pairs.
Select Create network.
The console opens the network's page. The network and its first subnet are created in one request. The network is Building until the platform finishes it, and then Active.
| Field | Rule |
|---|---|
| Network name | 1–63 lowercase letters, numbers, and hyphens. Unique within the project. |
| DNS servers | Optional. IPv4 or IPv6 addresses, separated by commas or spaces. Every subnet that you add to the network gets them. |
| Subnet CIDR | A private IPv4 block inside 10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16, with a prefix length, for example 10.0.4.0/24. The block starts at its first address. /31 and /32 blocks are refused, because they leave no address for the gateway. The console suggests the first private /24 that doesn't overlap your existing subnets. |
| Subnet name | 1–255 characters, without leading or trailing spaces, control characters, or characters outside the Basic Multilingual Plane, such as most emoji. Unique within the network. The console suggests the network name followed by -subnet-1. |
| Gateway (automatic) | The first usable address of the block, for example 10.0.4.1. You can't change it in this form. To use another address, edit the subnet afterward. |
| Tags | Optional key-value pairs. A key has 1–128 characters, and a value up to 256. |
When the block overlaps one of your subnets, the form warns you, and you can still create the network: Overlaps a subnet or address space you already have. Allowed, but the two cannot be routed together.
If you turn off Create a first subnet, the network is created without a subnet, and instances can't connect to it until you add a subnet.
You can also create a network while you create a virtual machine. In the creation wizard, Create network opens the same form. See Networking in the wizard.
Rename a network
In the console, go to NetworkingNetworks, and open the network.
Select Rename.
In Network name, enter the new name, and select Save.
The new name follows the same rules: 1–63 lowercase letters, numbers, and hyphens, unique within the project. Renaming changes only the name.
Change a network's tags
On the network's page, select the Tags tab, and select Edit.
Change the keys and values. To add a pair, select Add tag. To remove one, select × next to it.
Select Save. The console shows Tags updated.
Pairs without a key aren't saved.
Delete a network
Before you delete a network:
- Detach its ports from their instances, or delete the instances. While a port on the network is attached to an instance, the delete is refused.
- Delete its unattached ports on the Ports / devices tab.
- Detach its subnets from their routers. If a subnet is still attached to a router, the delete fails, the network shows Error, and the reason names the router.
On the network's page, select Delete.
Select Delete network. The network and its subnets are deleted.
You can also delete networks from the list. Select their check boxes, and select Delete. To delete a single network there, you type its name to confirm.
Add a subnet
You can't add a subnet while the network is Building.
On the network's page, select Add subnet. The Subnets tab opens with a new row.
Enter a name that's unique within the network, and a private IPv4 block, for example 10.0.5.0/24.
Optional: under Gateway, enter a gateway address inside the block. Leave it empty to use the first usable address of the block.
Select the check mark. The console shows Subnet added.
The new subnet gets the network's DNS servers and has DHCP turned on, and its allocation pool is derived from the block. To change these settings, edit the subnet.
Edit a subnet
On the network's Subnets tab, point to the subnet's row, and select the pencil icon.
Change the name, the gateway, the DNS servers, or DHCP. An empty gateway box keeps the current gateway. To remove the gateway, select Disable gateway.
Optional: under Host routes, select Add host route, and enter the destination block and the next-hop address.
Optional: under Allocation pool, select Add allocation pool, and enter the first and the last address of the range. Keep at least one range.
Select the check mark. The console shows Subnet updated.
The host routes and the allocation pools that you save replace the subnet's whole list.
| Setting | Rule |
|---|---|
| Gateway | An IPv4 address. |
| DNS servers | IPv4 or IPv6 addresses, separated by commas or spaces. |
| Host routes | An IPv4 destination block and an IPv4 next-hop address. |
| Allocation pool | An IPv4 start and end address inside the block. The end can't come before the start. |
You can't change a subnet's address block in the console. To use another block, add a subnet with it, move your resources to the new subnet, and delete the old one.
Important
If you remove a subnet's gateway, the internet access check of its instances fails with The subnet has no gateway, so traffic cannot leave it.
Delete a subnet
A subnet can't be deleted while a port or a router interface uses it.
On the network's Subnets tab, point to the subnet's row, and select the trash icon.
Select Delete subnet.
Troubleshooting
| Symptom | Cause | Resolution |
|---|---|---|
| Must be private: 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. | The block isn't private. | Enter a block inside 10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16. |
| Host bits must be zero: use the block start, e.g. 10.0.0.0/24 instead of 10.0.0.5/24. | The block doesn't start at its first address. | Enter the block's first address with the prefix length. |
| Too small: a /31 or /32 leaves no address for the gateway. | The block is a /31 or a /32. | Enter a larger block, such as a /24. |
| Your existing networks could not be loaded, so no CIDR was suggested and overlap is not checked. | The console couldn't load your existing networks. | Reload the page to get a suggested block and the overlap check. |
| The network's page shows This network has no subnet | The network's creation didn't complete, and it has no subnet. | Select Add a subnet now. If adding the subnet fails, select Delete this network, and create the network again. The reason is under What the provider reported. |
| Use a private CIDR: 10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16. | The new subnet's block isn't private. | Enter a private IPv4 block. |
| Failed to add subnet | The cloud refused the subnet. For example, the network is still Building, another subnet of the network has the same name, or the gateway is outside the block. | Wait until the network isn't Building anymore, choose another name, or fix the gateway. |
| Host routes need a valid destination block and next-hop IP, e.g. 10.20.0.0/24 via 10.0.4.254 | A host route has an invalid destination or next hop. | Enter a destination block and a next-hop address, both IPv4. |
| Enter both a start and end IP for the allocation pool, or leave both blank to use the default pool. | A range has only one end, or an end isn't an address. | Enter both ends of every range. Keep at least one range. |
| Failed to update subnet | The cloud refused the change. For example, a range is outside the block, or a range ends before it starts. | Correct the setting, and save again. |
| Subnet is in use by a port or router interface — detach it first, then delete. | A port or a router interface uses the subnet. | Delete or detach the ports, and detach the subnet from its router. |
| The delete of a network is refused. | A port on the network is attached to an instance. | Detach the port, or delete the instance, and delete the network again. |
| After a delete, the network shows Error. | The cloud refused the delete. The reason under What the provider reported names what still uses the network, for example a router that a subnet is attached to. | Detach the subnet from the router, or delete the network's remaining ports, and delete the network again. |