0
0
AwsConceptBeginner · 3 min read

What is a Route Table in VPC: Simple Explanation and Example

A route table in a VPC is like a map that tells network traffic where to go inside or outside the cloud network. It contains rules called routes that direct traffic from subnets to destinations such as the internet or other networks.
⚙️

How It Works

Think of a route table as a GPS for your cloud network. When data tries to leave a subnet, the route table looks at its rules to decide the best path to send that data. Each rule points to a destination, like the internet or another subnet, and a target, which is where the data should go next.

For example, if you want your servers to talk to the internet, the route table will have a rule sending traffic destined for outside your network to an internet gateway. If the traffic is meant for another subnet inside your VPC, the route table directs it internally. This way, the route table controls how data moves safely and efficiently in your cloud environment.

💻

Example

This example shows how to create a route table in AWS using Terraform. It includes a route that sends all internet-bound traffic (0.0.0.0/0) to an internet gateway.

terraform
resource "aws_route_table" "example" {
  vpc_id = "vpc-12345678"

  route {
    cidr_block = "0.0.0.0/0"
    gateway_id = "igw-12345678"
  }
}

resource "aws_route_table_association" "example_assoc" {
  subnet_id      = "subnet-12345678"
  route_table_id = aws_route_table.example.id
}
Output
Creates a route table with a route to the internet gateway and associates it with a subnet.
🎯

When to Use

Use route tables whenever you want to control how traffic flows in your VPC. For example, if you want some subnets to access the internet and others to stay private, you create different route tables with different rules. You also use route tables to connect your VPC to other networks, like a corporate data center or another VPC.

Real-world use cases include:

  • Allowing public web servers to access the internet.
  • Keeping databases in private subnets without internet access.
  • Routing traffic between different VPCs or on-premises networks.

Key Points

  • A route table contains rules that direct network traffic in a VPC.
  • Each subnet must be associated with one route table.
  • Routes define destination IP ranges and targets like gateways or instances.
  • Route tables help separate public and private network traffic.
  • Proper route table setup is essential for secure and functional cloud networks.

Key Takeaways

A route table directs network traffic inside and outside your VPC.
Each subnet uses one route table to decide where to send its traffic.
Routes specify destination IP ranges and where to send that traffic next.
Use route tables to control internet access and private network routing.
Correct route table setup ensures secure and efficient cloud networking.