Troubleshooting Subnet CIDR Issues for Load Balancer Setup on AWS

·

2 min read

Problem Overview

Public Subnet CIDR Setup:

  • Initial Setup: Public subnet CIDR block set to /28.

  • /28 CIDR Block: Provides 16 IP addresses, but fewer are available due to reserved IPs.

5 Reserved IP Addresses in Subnet:

  • Network address: First IP address.

  • Router address: Second IP address.

  • DNS server address: Third IP address.

  • DHCP and other services: Fourth IP address.

  • Broadcast address: Last IP address.

Load Balancer Issue:

  • AWS Load Balancer (ALB/NLB) requires at least 8 available IP addresses per subnet.

  • /28 Subnet: Insufficient IPs due to reserved addresses and existing usage.


Solution

CIDR Block Expansion:

  • Expanded CIDR block from /28 to /24 for the public subnet.

  • /24 CIDR Block: Provides 256 IP addresses, allowing sufficient IPs for Load Balancer.

Updated Public Subnet Setup:

public_subnet_id_1=$(aws ec2 create-subnet --vpc-id $vpc_id --cidr-block 10.10.0.0/24 --availability-zone ap-northeast-2a --query 'Subnet.SubnetId' --output text)
public_subnet_id_2=$(aws ec2 create-subnet --vpc-id $vpc_id --cidr-block 10.10.1.0/24 --availability-zone ap-northeast-2b --query 'Subnet.SubnetId' --output text)
echo "Public Subnet 1 ID: $public_subnet_id_1"
echo "Public Subnet 2 ID: $public_subnet_id_2"

SUM

Need for CIDR Block Expansion:

  • /28 Subnet: Only 11 usable IPs after 5 are reserved.

  • Load Balancer Requirement: Minimum 8 available IPs per subnet.

  • Action: Expanded to /24 to ensure enough IP addresses are available for the Load Balancer.


Next Post

  • Focus: Setting up an AWS EKS (Elastic Kubernetes Service) cluster.