Ravindra BagaleCourses & study guides मराठी Track your progress

Chapter 15: Amazon VPC — Subnets, Route Tables, NACL, NAT Gateway and Bastion Host

AWS Cloud

15.3 Subnets: default and custom subnets, CIDR and limits

A society has wings – A wing, B wing. In the same way a VPC has subnets. And every wing stands on one piece of land – just as every subnet lives in exactly one Availability Zone. Note: a single subnet never spreads across two AZs.

A subnet is a range of IP addresses inside the VPC's CIDR block. Every subnet sits in exactly one Availability Zone; it cannot span two AZs, and you cannot move it to another AZ later. Instances get their private IP from the subnet they are launched into.

  • Default subnets exist only in the default VPC: initially one /20 subnet per AZ with public IPv4 auto-assignment on. Check actual settings and whether each default subnet is still present.
  • Custom subnets are the ones you create. Each CIDR must fit inside an associated VPC range and not overlap another subnet in that family. Standard IPv4 subnet sizes range from /16 to /28. AWS documents separate IPv6 sizes.
Splitting a /16 VPC into /24 subnetsThe VPC 10.0.0.0/16 has 65,536 addresses. It is split into /24 subnets of 256 addresses each: 10.0.1.0/24, 10.0.2.0/24 and 10.0.3.0/24, up to 256 such subnets. For this ordinary IPv4 subnet AWS reserves 5 addresses: .0 network, .1 VPC router, .2 reserved for DNS, .3 future use and .255 broadcast, leaving 251 before any allocations. VPC 10.0.0.0/16 16 fixed bits · 2^16 = 65,536 addresses 10.0.1.0/24 256 addresses 10.0.2.0/24 256 addresses 10.0.3.0/24 256 addresses … up to 256 /24 blocks (default quota 200 subnets) Inside 10.0.1.0/24, AWS keeps 5 addresses: 10.0.1.0 network 10.0.1.1 VPC router 10.0.1.2 reserved for DNS 10.0.1.3 future use 10.0.1.255 broadcast Usable: 10.0.1.4 – 10.0.1.254 = 256 − 5 = 251 IPs

A /16 VPC has 65,536 addresses. Split into /24 subnets, each gets 256 addresses, and AWS reserves 5 in each ordinary IPv4 subnet (network, VPC router, DNS-related reservation, future use, broadcast), leaving 251 before allocations.

How many IPs can I really use? (5 are reserved)

For an ordinary AWS IPv4 subnet, 5 addresses are reserved. Eligible BYOIP ranges have separately documented behavior. In this example, use 10.0.1.0/24:

Address Reserved for
10.0.1.0 Network address
10.0.1.1 The VPC router
10.0.1.2 Subnet-relative address reserved for DNS. The VPC resolver is available at documented addresses.
10.0.1.3 Future use by AWS
10.0.1.255 Network broadcast address (AWS does not support broadcast, so it is reserved)

So a /24 gives 256 − 5 = 251 usable addresses, and a /28 gives only 16 − 5 = 11.

How many subnets can a VPC have?

  • Quota: 200 subnets per VPC by default (you can request more). A Region allows 5 VPCs by default.
  • Maths: a /16 VPC split into /24 subnets gives 2^(24 − 16) = 256 possible subnets: 10.0.0.0/24, 10.0.1.0/24, 10.0.2.0/24 … 10.0.255.0/24. With a 200-subnet applied quota and no other limiting resource, the quota is reached before the theoretical 256 blocks have all been used.

Our subnet plan

Subnet name CIDR AZ What runs there Type
web-public-1a 10.0.1.0/24 ap-south-1a Nginx web server, plus optional bastion and public zonal NAT for this example Public
app-private-1a 10.0.2.0/24 ap-south-1a PHP-FPM application server Private
db-private-1a 10.0.3.0/24 ap-south-1a Database server running MySQL or MariaDB, according to the chosen exercise Private

Create the subnets

  1. VPC → Subnets → Create subnet → VPC ID: select the assigned ID of the authorised society-vpc sandbox.
  2. Subnet name web-public-1a, Availability Zone ap-south-1a, IPv4 subnet CIDR block 10.0.1.0/24.
  3. Click Add new subnet and repeat for app-private-1a (10.0.2.0/24) and db-private-1a (10.0.3.0/24), both in ap-south-1a.
  4. Click Create subnet.
  5. Select web-public-1a → Actions → Edit subnet settings → enable auto-assign public IPv4 address only if desired for future eligible sandbox launches. Inspect current settings in the other two subnets and remember that the public route is configured separately.

For an approved CLI build, use the AWS CLI create-subnet reference with the verified VPC ID and intended zone. Inspect the returned subnet ID and address range before applying a separate address setting.

An ordinary /24 begins with up to 251 assignable IPv4 addresses. The Available IPv4 addresses column reports the current remaining count after allocations.

Ravindra Bagale's Tip

An ordinary /24 offers 251 assignable IPv4 positions before allocations, and a /28 offers 11. Count interfaces and addresses during scaling and replacement. You cannot enlarge an existing IPv4 subnet block, so size it using the expected peak and leave approved room to grow.

Lab

Use the offline capacity and overlap lab below. If also authorised to build three subnets in your sandbox, verify each subnet ID, Availability Zone and current IPv4 availability. Use the worksheet to check overlap before any create request. Clean up only the subnets the exercise created, after dependent resources have been removed.

Choose a placement that can actually hold the workload

A training centre deploys a workshop registration app in two Availability Zones. It has a role name for each subnet, and the first version runs. The team then adds an update feature that starts a new registration worker before stopping the old one. In one zone the launch succeeds. In the other, no suitable address remains in the selected app subnet. That zone has spare addresses in a different subnet, but the app was configured for the specific placement that ran out. The failure comes from where resources were placed and how much occupied space the release needed.

Here we turn the VPC address plan into working subnet choices. We will find which zone and parent network a subnet belongs to, why some of its addresses cannot be assigned, and why an accurate mathematical total can still be misleading during a deployment. We will also compare IPv4-only, dual-stack and IPv6-only placement. The role of a subnet and its IP addressing family are separate decisions, which is important once a project begins to use both families.

Begin with a real deployment question. Where can the public web entry place its interfaces? Where can a new worker overlap an old one during rollout? Which subnets could a supported data service use? Give every role a planned placement, network family, resource count at peak, and a reason for needing that placement. Include both routine use and the event most likely to consume extra addresses. An exercise with two small EC2 instances has different needs from a working load balancer or an autoscaling application with many replacements.

You can work through all the examples without making a cloud resource. The lab below uses a small, supplied inventory to model the placement checks. An optional console activity reads the same kind of fields in an approved AWS account. The model uses ordinary AWS IPv4 address reservations, checks zone-local remaining capacity, tests mathematical IPv6 range placement and explains the exact limits of an offline result. The model does not fetch or change a VPC.

Locate a subnet inside its VPC and its Availability Zone

A VPC owns address ranges in a Region. A particular subnet chooses a slice of one applicable VPC address range and a location in one Availability Zone. A virtual machine launched into that subnet gets its initial network location there. Its corresponding interface obtains private IPv4 or IPv6 addressing according to the subnet family and chosen resource settings. Two machines with matching private addresses in separate networks are not automatically neighbours. The local context includes the network, placement and actual interface, not just the dotted address someone put into a ticket.

For an ordinary IPv4 network, a VPC of 10.76.20.0/22 covers third numbers 20 through 23. It could contain a web subnet 10.76.20.0/26 and an app subnet 10.76.20.128/26. Both are part of the VPC, and their ranges do not overlap. Assign zone names independently. Nothing about the fourth field of an IPv4 address encodes the physical Availability Zone. An app B subnet at 10.76.20.192/26 can be placed in a different zone under the same VPC. The selected zone is part of the actual subnet configuration.

Apply this to a common operational mistake. Someone labels two subnets app A and app B. A load balancer setup then rejects them because both are in the same zone. The names and even the clearly distinct CIDRs are not evidence of distinct placement. Read the Availability Zone, zone ID and VPC ID in the subnet details. When coordinating between AWS accounts, compare supported Availability Zone IDs because the letter in an AZ name can differ across accounts. An address spreadsheet should include the relevant ID as well as the friendly role and zone name.

You cannot move a subnet between zones in place, and you cannot enlarge its existing IPv4 CIDR by editing the slash. If the placement or block is wrong, create a suitable new subnet under the intended design and plan how to replace or move the workload according to that service's procedures. A service may need a configured subnet group, new instances or a rebuilt network attachment. Read its specific behavior. Rolling over to new placement changes which route table, network ACL, addresses and private endpoints the workload may use. A migration is therefore more than assigning a new label.

A custom subnet can be the size of its containing block when a single subnet is appropriate. If the project requires separate routing, availability or management roles, its subnet slices must fit without overlapping. If the VPC has multiple associated blocks, ensure each subnet range is contained within an appropriate association. A proposed IPv4 range that straddles two adjacent VPC blocks cannot be treated as a subnet simply because the combined union contains its addresses. Record which specific association owns each placement and verify the approved range for the requested subnet.

The zone relationship also helps explain availability. If one zone loses its working registration capacity, the deployment can still need other zone capacity plus a working way to send traffic there. A subnet in a second zone is space for a deployment. It does not establish that any resources actually run there or that they meet the expected recovery demand. Check the app, entry and data requirements separately across the placements rather than claiming the entire service is resilient based on counting subnets.

Distinguish the default subnet flag from routing and addressing

When AWS creates a default VPC, it normally creates a slash-20 default subnet for each Availability Zone present in the setup. The initial subnets use a main route table with an internet-gateway route and request public IPv4 addressing for compatible launches. Each default subnet has a flag showing it is the default for its AZ. A nondefault subnet is an independently created placement, including an added subnet inside a default VPC. The flag can tell you which placement can be selected as a zone's default. The flag does not describe every route or launch choice in today's account.

In a default VPC, a separately added subnet can use its main route table. If that table has a direct internet-gateway route, the added subnet may be a public placement even though its default marker is false. It normally has automatic public IPv4 assignment disabled unless enabled or created under a workflow with a different default. The documented EC2 launch wizard case is one exception for nondefault subnets. An actual EC2 launch can also override the subnet's default in supported configurations. Check the current subnet attribute and the newly created interface instead of assuming the launch result from the subnet name.

To see the difference, imagine an authorised web test on a subnet with a direct IPv4 route to an attached internet gateway. An instance is created without a public IPv4 mapping. A private client may still call its web address if it has the appropriate route and permission. The expected direct external IPv4 browser path cannot borrow a mapping from another instance in the subnet. Keep the route and address tests on different lines. Enabling auto-assignment affects future eligible launches, rather than making the existing address immediately usable from outside.

Now look at a custom app subnet. Its operator might arrange outbound dependency traffic through a NAT gateway or an approved private endpoint. The app can use required outside services without allowing unsolicited inbound public connections in that design. The actual definition of each path belongs in its route-table and endpoint details. If the app has no outbound internet dependency, no internet path is needed merely because it is a nondefault subnet. A direct route through an internet gateway, a NAT-routed outbound path, an attached private-network path, and an isolated local-only placement are different outcomes.

Write down the four independent checks on the console. Read the VPC identifier, the Default for AZ flag, the effective route table and the subnet's auto-assignment settings. Then inspect the particular interface and required security rules. If a subnet is called private but a new directly reachable public interface appears unexpectedly, check the exact launch request and network path with the owner. Do not repair that discrepancy by changing the entire VPC main route table before learning which subnets use it. A careful investigation identifies scope before changing shared resources.

Find the addresses AWS holds back

Use the first web subnet in the example, 10.76.20.0/26. Its address range starts at 10.76.20.0 and ends at 10.76.20.63. Ordinary AWS IPv4 subnets reserve the first four and the last position. Here zero denotes the network, one is reserved for the VPC router, two is held back for DNS related purposes, three is reserved for future use, and 63 is the final reserved position. This leaves 59 assignable positions under the example's assumptions. You'll see workbooks that count 62 after removing only first and last. That is not the usual AWS reservation calculation.

DNS needs careful wording. AWS reserves the base plus two in each subnet. A workload does not thereby get a completely different Amazon-provided VPC DNS resolver at every subnet's base plus two. AWS describes the resolver using the primary VPC IPv4 range plus two, as well as its documented link-local addresses. For the exercise, treat the subnet-relative position as reserved. If you are diagnosing actual DNS behavior, inspect the applicable VPC and DHCP name-resolution settings. The reservation list is not a recipe for configuring a local DNS server at the shown address.

The last position is held back for the network's broadcast address convention. VPC does not support IPv4 broadcast in the ordinary way. The reserved address still counts when explaining why the last candidate cannot be assigned. AWS documents different behavior for eligible IPv4 ranges brought through Bring Your Own IP, commonly called BYOIP. Keep the five-reservation arithmetic scoped to ordinary example subnets. If a particular environment uses a different supported address arrangement, apply its official limitations and observe the actual available capacity.

Try doing the same count for a second slash-26 subnet starting at 10.76.20.128. The first four held-back positions are now 128, 129, 130 and 131 and the last is 191. The first ordinary usable candidate ends in 132. This explains why an experienced person does not find the reserved addresses by checking for fourth field zero or 255 only. They read the start and end of the specific subnet. A slash 28 has just 16 positions and typically 11 usable. That is enough for some very small roles, but capacity can disappear quickly with additional interfaces.

The subnet's total usable address capacity and its current availability answer different questions. A brand-new slash 26 in the example starts with 59 positions after reservations. After 47 ordinary address allocations it has 12 available. Inspect the actual subnet's current available IPv4 address count rather than treating a total as continuing headroom. The count reflects allocations and can change during deployments and managed operations. The usual upper bound also is not a maximum number of instances, because each instance or another service can allocate several addresses or interfaces. Identify the unit being counted.

For a practical worksheet, put the prefix and raw total in the first line. Next identify the relevant reservations. In a different column put current allocated use and current free IPv4 positions from the actual environment. Another column records the estimated next deployment's extra demand. This helps two support people understand what they are comparing. If one person writes 251 and another writes 9, they may be looking at different valid measurements. The more useful next question is which value represents what the release needs now.

Calculate failure and rollout capacity per location

Return to the registration app. It has 47 allocated IPv4 positions in app A and 55 in app B, each from an ordinary slash 26. The resulting free counts are 12 and 4. The next rollout creates six new network attachments per selected zone before releasing any old ones. App A could accommodate that simple additional demand from its address-count point of view. App B cannot. Adding both free counts gives 16, but combining the numbers does not let the app place six new interfaces in B when the deployment explicitly requires that zone. Read the minimum remaining capacity where the demand lands.

A capacity-only result does not guarantee a successful launch. The account can also have quotas for a given service or EC2 family and limits on network interfaces and their address assignments. A selected instance type or service configuration may not be available in a particular placement. Check the actual deployment error and provider status. An insufficient-free-address result leads to a different investigation from an unavailable resource type. If there is a managed scaling component, inspect its current logs and resource records before assuming that a count alone explains the observed fault.

When a team scales across zones, it can revise the rollout sequence if that meets availability and deployment requirements. Starting a smaller batch and intentionally waiting for prior releases may fit. Another option is to create a larger suitable subnet and plan the workload migration. Free space in the wider VPC reveals whether a suitable new allocation is possible. It cannot enlarge application B's active block. A choice that starts fewer copies could affect readiness or load capacity, so coordinate with the app owner and test the rollout in the planned context.

There is a separate case for failover. Suppose each zone usually serves 20 active workers while other components occupy addresses there too. If zone A fails, the surviving zone may need to run a larger number of workers. Identify whether the proposed topology supports that capacity and whether the load and state services can still be reached. You might reserve more room in each application subnet for that case. You also need to know whether the failure plan keeps the same placement or uses a separate subnet of the same role. A regional sum of steady-state addresses hides the actual bottleneck.

Managed services, load balancing and private interface endpoints can allocate addresses in the subnets you select. Include their requests and replacement buffers in peak planning. Separate service-specific requirements from the generic five-address arithmetic. For example, the Application Load Balancer's documented availability-zone-subnet address and scaling requirements matter even before evaluating the app's instances. In an occupied subnet, its current free count is often the immediate question. Look up the actual service documentation and avoid setting the same prefix on every role simply for visual symmetry.

Also evaluate service quotas independently of mathematical packing. AWS lists a default adjustable quota of 200 subnets per VPC and five VPCs per Region. A slash-16 block can mathematically be divided into 256 slash-24 ranges, so the example 200 quota could be hit before exhausting that set. Check the applied quotas in your actual account and Region, and the number of existing objects counted against each. If another assumption already limits the design, such as available CIDR space or the intended zones, requesting a quota increase alone will not resolve it.

Explain IPv6 choices without reusing IPv4 assumptions

IPv6 uses 128 bits and a different notation. An IPv6-only subnet has IPv6 addressing and no private IPv4 address for a launched EC2 instance. A dual-stack subnet supports both IPv4 and IPv6. A VPC needs an associated IPv6 range for IPv6 subnet addressing. The parent VPC also has IPv4 even if a particular subnet is IPv6-only. Current EC2 documentation requires instances built on the Nitro System for IPv6-only subnets; check the actual instance family and service dependencies. A new IPv6 CIDR in the VPC does not turn existing workloads into dual-stack resources by itself.

AWS currently documents possible IPv6 subnet prefix lengths of slash 44, 48, 52, 56, 60 and 64. The chosen range must still fit within an associated VPC IPv6 block, and a specific workflow or service can impose additional constraints. If your VPC has a slash 56, it cannot supply a slash 52 subnet, because slash 52 represents a larger address set than the parent. Slash 64 is common in examples. Current documentation and the actual allocation matter when making a design decision. Plan the range and read the chosen workflow rather than treating the example's slash 64 as the only possibility.

Use the reserved example 2001:db8:7600:1200::/56 on paper only. It contains 256 equal slash-64 blocks because there are eight additional prefix bits between slash 56 and slash 64. It also contains 16 equal slash-60 blocks. Inside 2001:db8:7600:1210::/60, the fourth field can range from hexadecimal 1210 through 121f. A slash 64 child at 2001:db8:7600:1212::/64 lies inside that larger child. You cannot allocate both as separate overlapping subnets in one plan. The IPv6 range has many addresses but still needs clean boundaries and exact association.

AWS reserves the first four and final addresses of an IPv6 subnet for the documented uses. Counting addresses is much less likely to drive the size decision in a common slash-64 example than it is for a small IPv4 subnet. Placement, supported service requirements, planned route boundaries, and a manageable allocation scheme still matter. Do not apply the IPv4 broadcast explanation to IPv6. Read the current reservation table and consider who will operate the DNS, gateway and firewall state for IPv6 independent of IPv4.

Some AWS IPv6 ranges are intended for public reachability, while IPAM can support eligible private IPv6 ranges. AWS does not route those private IPv6 addresses directly through its internet gateways. With suitable public IPv6 addressing, an internet gateway or egress-only internet gateway can support the applicable route design under the proper controls. Giving a server an IPv6 address does not alone create that path. Equally, making an IPv4 path private does not automatically close an independently configured IPv6 path. The control should explain each family separately.

To add IPv6 to an approved existing application, first choose an address range and documented test placement. Confirm that runtime listeners and dependencies can use the chosen family. Check how the name will receive its IPv6 DNS record and whether clients that resolve it can take the intended route. A healthy IPv4 test does not test IPv6, and an address printed in the console does not demonstrate that a service is listening on it. Verify the established IPv4 path as a separate control during the candidate test. Also distinguish IPv6-only dependencies that need translation, such as a supported DNS64 and NAT64 design, from native dual-stack routing when the actual service supports both families.

Run the capacity and overlap worksheet

Use Python 3 and a terminal. The fixture has two occupied IPv4 app subnets, a planned deployment requesting six additional address allocations in each subnet, and two possible IPv6 slices. It uses standard library range calculations. The AZ IDs and workloads are invented. Each free count is calculated from the supplied allocation number. Predict which app placement can accept the whole batch and why the two available counts cannot be pooled. Then predict whether the proposed slash-64 IPv6 subnet conflicts with the existing slash-60 allocation or with the overall parent.

python3 - <<'PY'
from ipaddress import IPv4Network, IPv6Network

parent = IPv4Network('10.76.20.0/22')
placements = [
    ('app-a', 'zone-a', IPv4Network('10.76.20.128/26'), 47),
    ('app-b', 'zone-b', IPv4Network('10.76.20.192/26'), 55),
]
requested = 6
free_by_zone = {}
for role, zone, block, allocated in placements:
    assert block.subnet_of(parent)
    usable = block.num_addresses - 5
    free = usable - allocated
    assert 0 <= free <= usable
    free_by_zone[zone] = free
    print(f'{role} | {zone} | {block} | {allocated} in use | {free} free')
assert not placements[0][2].overlaps(placements[1][2])
assert sum(free_by_zone.values()) == 16
assert free_by_zone['zone-a'] >= requested
assert free_by_zone['zone-b'] < requested
print('Six additions fit in zone-a, but only four places remain in zone-b.')

ancestor = IPv6Network('2001:db8:7600:1200::/56')
existing = IPv6Network('2001:db8:7600:1210::/60')
conflict = IPv6Network('2001:db8:7600:1212::/64')
candidate = IPv6Network('2001:db8:7600:1222::/64')
assert all(block.subnet_of(ancestor) for block in [existing, conflict, candidate])
assert conflict.overlaps(existing)
assert not candidate.overlaps(existing)
assert sum(1 for block in ancestor.subnets(new_prefix=64)) == 256
print(f'{conflict} fits the parent but overlaps {existing}.')
print(f'{candidate} fits without that conflict.')
PY

Read the first two lines together. Both subnets have the same prefix and usable capacity. The different in-use counts make the next launch outcome different. The assertion checks that the values represent a valid allocation between zero and the example maximum. The script then calculates a 16-address total, which might mislead you without the two zone-specific decisions. The shortage at B is two additional positions for this hypothetical batch. If you change the request to four, adjust the final assertions to represent the new expected outcome and rerun the exercise.

The IPv6 checks exercise containment and overlap separately. Both proposed slash-64 ranges fit inside the VPC's example parent. Only the one in the 121 range also falls inside the earlier slash-60 allocation. Two rows can therefore pass a parent-boundary test while one fails the allocation test. The function counting how many networks fit under the parent counts hypothetical equal slash-64 blocks across the entire original range. It does not say that all remain allocatable after earlier subnet choices or applied AWS quotas.

Complete the lab by writing a short decision for app B. Mention the current free count, the requested count and whether moving the deployment to a different phase or creating a new placement suits the requirement. For that new placement, record an appropriate distinct subnet range, AZ, effective route table and permissions to check. Keep the roles separate from the numeric calculation. The exercise uses no network, stores data only in memory, and exits without creating cloud state or files.

Work from subnet details in an authorised environment

With permitted read access, open the VPC or EC2 subnet list in the correct Region and filter to the intended VPC ID. Write down one existing subnet's ID, its zone and the actual CIDR for each family. Record its current available IPv4 addresses if it has IPv4. Compare that figure to a calculation of the maximum usable under its documented reservation scheme. Use the subnet detail page to inspect its effective route table and associated network ACL. Confirm auto-assignment separately from the current workload's own addresses. Be careful not to edit shared resources during an inventory.

If you are building a separately authorised sandbox, select the exact VPC ID and intended Availability Zone while creating each approved subnet. Use canonical ranges aligned to the address plan. After the create action, check the address family, actual CIDR and availability, and verify the returned subnet ID. Review the initial route association, including whether it implicitly uses the VPC main table. An explicit table may be needed for your design. A tag such as app-private helps people find a resource but supplies no route, security rule or address policy. Choose settings by intended traffic behavior, not by tag meaning.

Before cleaning up a sandbox subnet, verify its ID and dependants. Running app interfaces, endpoints or provider-managed resources can prevent deletion. Identify the owner of each interface and use the owning service's supported cleanup workflow. A removed subnet's block returns to the VPC's available subnet pool, but the equivalent-looking replacement has a new ID and may not have the same route or ACL associations. Delete only the lab subnets that are in your cleanup plan. The read-only inventory and the offline worksheet themselves need no AWS deletion.

Use the actual launch evidence to diagnose an exhausted subnet

The project's operator hears that a launch failed in app B. Begin by asking for the operation, its time and the requested subnet ID. The label in the ticket could be an older deployment label. Confirm the current template or service configuration actually selected the expected identity. A template can retain the old subnet ID after a replacement is created. If you see an exact subnet ID in the event, compare it with the current ID in the network inventory. A route-table or ACL investigation for the new placement does not explain a launch request that still targets the old one.

Now inspect which other resources occupy the target. An interface has an owner and attachment information. Look at the approved inventory for the selected subnet. Low capacity can reflect growing application targets, a service endpoint, or another workload using a shared placement. Reports of running machines may omit interfaces and secondary addresses. The shortfall is not evidence that an interface can be detached safely. Some interfaces are managed by services and may provide a route or private access used by many workloads. Record actual resource ownership and consult the corresponding service before changing it.

Consider a busy rollout with 55 addresses allocated in B and four reported free. A service status says six additional interfaces will be requested. The release configuration can be changed to build two at a time if its documented deployment rules and minimum running capacity allow that. After the first pair comes online, two previous copies must release the expected allocations before the next pair starts. Pause temporarily if the retirement does not release the interfaces you expected. Address counts and app health are separate signals. A conservative batch size is not proof that application capacity remains adequate, so include success and latency checks on a useful operation.

Suppose design review leads to a new larger placement instead. Use a planned nonoverlapping block in the intended zone. The old instance's network interface and IP do not move just because you have created another subnet. Plan how the supported workload will be redeployed or reattached, how a load balancer will see healthy new targets, and how the private DNS and service policies refer to them. If the earlier policy permits a narrow source CIDR, it may need a deliberately scoped update. New placement should be tested on the normal operations before moving production traffic.

The stateful part of a deployment needs special care. A self-managed database might require replication, a migration or a restore plus a coordinated connection switch. A managed database uses its own subnet-group and migration procedures. Replacement is not a universal copy-and-delete operation. Verify the backup and the meaning of the data result before removing any prior resource. When an interview question says move the subnet, respond with the actual workload migration decision rather than assuming the old working IP will follow.

Close the issue with the specific evidence. A useful note might say the rollout requested six additional IPv4 allocations in app B, found four free, and switched to an approved sequence of two concurrent replacements after establishing minimum available app capacity. Say how the process verified a completed enrolment, which zone handled it and whether prior interfaces were released. If a new subnet was required, identify the actual old and new IDs and show how the changes were limited to that app. This review helps operators understand which boundary mattered and makes the next rollout easier to check.

Compare two listeners when only one IP family is healthy

For a dual-stack launch, try a written troubleshooting example before using a real network. A visitor opens a hostname from a client that can use both families. The DNS response has an A record for an IPv4 address and an AAAA record for an IPv6 address. IPv4 succeeds. An IPv6-only client cannot reach the proper application response. You cannot infer the failing layer from the fact that the page works on one laptop. Some clients may pick an alternate eligible path, so the symptom can vary. Compare forced-family tests from suitable clients when those are authorised and available.

Begin with the returned address for each family and confirm which application entry it represents. For IPv6, verify the entry has the correct address and the subnet association. Confirm the applicable IPv6 gateway route and the traffic rules that cover that family. The destination needs a listener that accepts the chosen connection. If DNS points to an old entry, changing the new entry's IPv6 permissions would not prove what the client actually reached. If DNS is correct and the path fails, inspect the next boundary in order. Record whether the IPv6 request timed out, connected to a different site, or received an actual application error.

A private IPv6 path across a connected network has different expectations from direct public IPv6. If the service needs to reach an internal endpoint through peering or another approved connection, test from the expected source networks and resolve the intended private hostname. An egress-only gateway designed for supported outbound internet traffic cannot replace a missing private route to the internal service. Conversely, a valid private endpoint says nothing about whether outside IPv6 clients can initiate the desired public connection. Write a separate row for the purpose of each path.

If the route and firewall model appears correct for both families, check the service's protocol and expected application result. For example a healthy load balancer listener may return a failure because the selected app has no available backend, rather than because the chosen family cannot reach the entry. Use the response to update the investigation. When an IPv6 fix is applied, run the original IPv4 request again from the appropriate source as a control. Verify the intended operation in both families, the wrong or unauthorised path behavior from appropriate test contexts, and the recorded constraints. That supplies stronger evidence than a screenshot of two addresses in a subnet panel.

Explain subnet mistakes from concrete evidence

Can an IPv4 slash-24 subnet hold 256 ordinary EC2 instances?

It has 256 total positions under the prefix. Ordinary AWS IPv4 subnet reservations leave 251 usable addresses, and already allocated interfaces reduce the number currently available. Some workloads require more than one address, so the number of possible instances depends on the design. I would inspect the target subnet's available count and the expected address demand at peak.

Is a single subnet in two Availability Zones possible?

No. A subnet has one Availability Zone. A VPC can contain subnets assigned to different zones in its Region. Inspect the actual zone or zone ID for each placement. Then check whether the application and its dependencies really use the intended placements, because two subnet IDs tell you that places exist, not that traffic can fail over.

How would you fix a full subnet when the VPC has spare CIDR space?

I would first verify the reported shortage against the actual in-use and free addresses, the service's requirements and deployment batch. The existing IPv4 subnet prefix cannot expand in place. A supported rollout sequence might reduce simultaneous demand, or a new appropriately sized subnet can provide a replacement placement. Validate the new route and policy before transitioning the workload.

Does enabling IPv6 for a VPC require every subnet to have the same address family?

No. The design can use multiple supported types, including IPv4-only, dual-stack and IPv6-only subnets. Verify service and instance support, associated ranges and prefix lengths, routing, listeners, DNS answers and each family's controls. A valid IPv6 address block says where addresses may come from. The actual path still has to serve the required operation.

In your own notes, describe a case where you would request another subnet and another case where you would request more addresses in the operating plan. Include which placements are involved and which controls will differ. Discuss the intervals and the deployment behavior with another learner. The same workbook arithmetic can support several designs, so each answer should show which workload requirement led to the choice.

Predict the outcome from the actual subnet fields

  1. How many ordinary usable addresses are available before allocation in a slash-27 IPv4 subnet?

    Answer and reasoning

    The prefix leaves five varying bits. There are 32 positions. Subtract five for ordinary AWS reservations, leaving 27 before any allocations.

  2. App A has 12 free IPv4 addresses and app B has four. A change requires five new attachments in both zones. Can the app deploy both batches as requested?

    Answer and reasoning

    It exceeds the modeled address capacity in app B, even though the two free counts add up to 16. A zone-constrained attachment needs a free address in the actual subnet it uses.

  3. Can you place a slash-52 IPv6 subnet under a slash-56 parent if both are valid prefix sizes for a subnet?

    Answer and reasoning

    No. The shorter slash-52 prefix describes more addresses than the slash-56 parent. Size rules for a subnet and containment within the associated VPC range are separate conditions.

  4. Does turning on public IPv4 auto-assignment add an internet-gateway route?

    Answer and reasoning

    No. The addressing attribute affects the eligible future interface or launch. The effective route table, attached gateway and traffic permissions must be checked independently.

Revision cards for practical subnet work

Zone and parent

A subnet belongs to one VPC and one Availability Zone. Check which associated range contains it, and ensure ranges do not overlap.

Total and available capacity

Compute the raw prefix size and ordinary reservations. Read the current free count and compare it with peak additional address allocations in that actual subnet.

Default, public, or auto-assign

Read the default-subnet flag, effective route, launch setting and interface separately. A name tag does not affect any of them.

IPv6 adds independent choices

Verify prefix sizing, parent containment, family support and route policy. Check a real IPv6 client operation separately from the IPv4 control.

Official references