VPC (Virtual Private Cloud) is a networking service in AWS that allows you to create a private, isolated network for your resources within the cloud. Think of it as building your company’s own private network where all employees (resources) can connect, share, and communicate securely.
Why is VPC Important?
- Network Isolation: You can create a private network to keep your resources isolated from others.
- Control: You manage your IP addresses, subnets, routing tables, and security.
- Security: Allows for secure communication between your resources with tools like Security Groups and NACLs.
- Custom Networking: You decide how resources communicate within the VPC or the internet.
VPC Network Design
- A VPC exists within a specific AWS region.
- Inside the VPC, you can create subnets (smaller networks) in different Availability Zones.
- Resources (like EC2 instances) are launched inside these subnets.
IP Addressing in VPC
IP addresses within VPC follow the IPv4 private IP address range. These ranges are:
- 10.0.0.0/8 → 16,777,216 IPs
- 172.16.0.0/12 → 1,048,576 IPs
- 192.168.0.0/16 → 65,536 IPs
You can choose any of these ranges for your VPC.
Why Only 255 IPs in Some Cases?
- IP addresses are defined using CIDR (Classless Inter-Domain Routing).
- CIDR allows you to divide an IP address range into smaller chunks or blocks.
Example:
- 192.168.0.0/24 → Gives you 256 IP addresses (2^8 = 256).
- 256 - 5 = 251 usable IPs (AWS reserves 5 IPs).
- 192.168.0.0/16 → Gives you 65,536 IPs (2^16).
What is CIDR and Why Was It Introduced?
CIDR (Classless Inter-Domain Routing) was introduced to overcome the limitations of the traditional class-based IP addressing. It allows for:
- Efficient allocation of IP addresses.
- Subnetting (breaking networks into smaller segments).
Understanding /24 in IPv4 (CIDR Notation)
- IPv4 addresses are 32 bits.
- The /24 means the first 24 bits of the address are fixed (network part), and the remaining 8 bits are for hosts.
Example: 192.168.0.0/24
- First 24 bits → Network: 192.168.0
- Last 8 bits → Hosts: 0-255.
If you change to /16:
- Network: 192.168 (16 bits fixed).
- Hosts: 0.0 to 255.255 → 65,536 IPs.
Practical Scenario for VPC
Imagine a company in India:
- Company Requirement: All employees must securely connect, share resources, and communicate.
- Solution: Create a VPC in AWS.
- Region: Choose India (e.g., ap-south-1).
- Private IP Range: 10.0.0.0/16 → Gives 65,536 IPs.
- Subnets: Divide IPs into smaller subnets:
- 10.0.1.0/24 → For the HR team.
- 10.0.2.0/24 → For the Dev team.
- 10.0.3.0/24 → For Testing.
- Security: Use Security Groups and NACLs to control access.
- Internet Access: Attach an Internet Gateway for public resources.
Summary
- VPC: A private network in AWS.
- CIDR: Allows flexible IP allocation (e.g., /24 = 256 IPs).
- Private IP Ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.
- Subnetting: Divides your VPC into smaller parts for better management.
- Use VPC to build secure and scalable cloud networks.
By understanding VPC, CIDR, and IP addressing, you gain the power to design robust, secure cloud architectures. 🚀
