Virtual networks and subnets
A network is an address and forwarding boundary
A virtual network is a software-defined networking environment for cloud resources. Subnets divide its address space into smaller ranges. A virtual network interface (NIC) connects a VM or other supported resource to a subnet. A route tells the network where to send a packet; a security policy determines whether the traffic is permitted. These are separate decisions. A subnet alone does not isolate workloads from each other.
Imagine an online bookstore with a frontend, API and database. Give each tier its own address range so operators can track capacity, apply appropriate policies and change the application without renumbering every resource. The following examples are offline designs, not deployable configurations.
Read a CIDR range
IPv4 uses 32 bits. In 10.42.0.0/24, the prefix length 24 fixes the first 24 bits, leaving 8 bits for addresses. The total is 2^(32 - 24) = 256 addresses, from 10.42.0.0 to 10.42.0.255. A /26 has 64 addresses, and its boundaries in the last octet are 0, 64, 128 and 192. 10.42.0.70/26 is a host address with prefix, not the canonical network address; the containing network starts at 10.42.0.64.
Cloud platforms reserve some of these addresses. Ordinary AWS and Azure IPv4 subnets reserve five; Google Cloud primary IPv4 subnet ranges reserve four. Thus a /26 has 59 or 60 assignable addresses respectively before additional service requirements. Do not apply a generic subtract-two rule. Special subnet types, service minima, and IPv6 have separate rules.
Allocate a growing application
Use fictional private space 10.42.0.0/22 (1024 addresses, ending at 10.42.3.255). Assume the existing connected office uses 10.50.0.0/16. The design needs 80 API, 40 frontend and 20 database addresses, including NICs and service overhead, before a 25% growth allowance. Round upward: 100, 50 and 25. For the conservative five-address reservation model, choose /25 (123 assignable), /26 (59), and /27 (27).
| Tier | CIDR | Planned addresses | Assignable (five reserved) |
|---|---|---|---|
| API | 10.42.0.0/25 | 100 | 123 |
| Frontend | 10.42.0.128/26 | 50 | 59 |
| Database | 10.42.0.192/27 | 25 | 27 |
The ranges end at .127, .191 and .223, so they do not intersect. Keep 10.42.0.224/27 and the three remaining /24 ranges unallocated for expansion. Total unallocated raw addresses: 800. The example is a single logical placement unit; the next lesson shows how to distribute it across zones.
A second team proposing 10.42.0.160/27 overlaps the frontend range. A proposed subnet of 10.43.0.0/24 falls outside the approved parent. Reject both before provisioning. Check office, partner, VPN, and future peering ranges too. Separate unconnected networks may reuse a range, but connecting them later can require renumbering or specialized translation.
Routing and address assignment
A NIC usually receives a private/internal IP from its subnet. Some services can attach more than one NIC or assign additional addresses, subject to limits. A public/external IP provides a possible internet-facing address, not proof of connectivity. IPv6 uses 128-bit addresses; prefix allocations and public reachability depend on provider-specific IPv6 behavior. A globally scoped IPv6 address still needs routing and policy. Do not subtract five from IPv6 capacity or assume IPv4 NAT rules apply.
A route normally matches a destination prefix and selects a next hop such as a gateway or virtual appliance. In a simple longest-prefix model, 10.50.0.0/16 -> office-gateway wins over 0.0.0.0/0 -> internet-gateway for 10.50.2.8. Actual cloud route priorities, policy routes and route origins can change selection; use the documented evaluation rules. Route propagation means eligible routes may be learned or distributed automatically, for example through a VPN routing integration; it does not mean every connected network becomes reachable.
Check the reverse path too: an office route to 10.42.0.0/22 must lead back to the cloud. Firewalls and application authorization must allow the intended flow. A route alone cannot make a database public or safe.
Practice and common mistakes
- Calculate the capacity of a /27 with five reserved addresses: 32 - 5 = 27. Would 28 NICs fit? No.
- Compare
10.42.1.0/24with10.42.0.0/22: the first is contained in the second, so it is a candidate for an unused subnet, but cannot be treated as a non-overlapping independent network for peering. - Keep a register of network owner, region, CIDR, purpose, assigned capacity, future reserved ranges and linked networks. Review the register before expanding.
Common mistakes: counting VMs instead of all IP consumers; using a non-aligned network prefix; selecting a block only large enough for today; expecting a firewall to correct overlap; treating a public route as public access. Continue to cloud network scope differences for provider-specific placement.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Virtual networks and subnets — knowledge check
Choose the best answer for each offline scenario.
How many raw IPv4 addresses are in a /26?
An ordinary AWS /27 subnet has five reserved addresses. How many are assignable before other constraints?
Which candidate overlaps 10.42.0.128/26?
80 interfaces need 25% growth headroom and five addresses are reserved. Which is the smallest listed sufficient subnet?
The cloud has a route to the office but the office has no return route. What should you do?