Skip to content

How do I change the subnet mask for the default subnet of my default Amazon VPC?

2 minute read
0

I want to change the subnet mask for the default subnet of my default virtual private cloud (VPC) in Amazon Virtual Private Cloud (Amazon VPC).

Short description

You can delete the default subnet for your default VPC and replace it with customized configurations.

Resolution

  1. Delete the default subnet for your default Amazon VPC in an AWS Region.
  2. Create a new subnet with your preferred subnet mask size. Be sure that the new subnet is part of your default VPC in the same AWS Region.
    Note: The first four IP addresses and the last IP address in each subnet CIDR block aren't available for your use. These IP addresses can't be assigned to an instance.

Migrate to a smaller subnet CIDR

When you shrink a subnet CIDR, the new CIDR is a subset of the old one, so the two ranges overlap. Amazon VPC doesn't allow overlapping subnets in the same VPC. You must delete the old subnet before you create the smaller one. If an Auto Scaling group uses the subnet, then migrate subnets in sequence to keep the group healthy.

Migrate the empty subnet

Complete the following steps:

  1. Remove the empty subnet from the Auto Scaling group.
  2. Delete the empty subnet.
  3. Create the new, smaller subnet in the same CIDR space.
  4. Add the new subnet to the Auto Scaling group.

Migrate the occupied subnet

Complete the following steps:

  1. Remove the occupied subnet from the Auto Scaling group.
  2. Detach the running instance from the Auto Scaling group. When you detach, choose the option to launch a replacement instance, so the Auto Scaling group launches a new instance in the subnet you already migrated. Then terminate the detached instance.
  3. Delete the old subnet.
  4. Create the new, smaller subnet and add it to the Auto Scaling group.

Related information

Default VPCs

How Amazon VPC works

Subnet sizing for IPv6

IP addressing for your VPCs and subnets

AWS OFFICIALUpdated 21 days ago