After connecting an internet gateway to the VPC, we must configure the network traffic routes to continue creating a public subnet. Let’s first go over the concept of VPC routing and the route tables needed to implement it.

VPC router

A VPC router is a fully managed AWS networking component that controls the network traffic routing within and outside a VPC. It is a crucial element that upholds the essential traffic routing rules, which can also be configured in accordance with our needs. It operates across all AWS Availability Zones to guarantee high availability and uses a Network+1 address in each subnet for the router network interface.

We don’t need to worry about a VPC router’s availability because AWS manages and maintains it. For controlling and specifying the network path, we can use the route tables and associate them with the subnets.

Route tables

Route tables in an Amazon VPC define the network traffic path using the rules contained within it, known as routes. When we create an Amazon VPC, it comes with a default route table known as the main route table. The main route table is automatically associated with subnets that are not explicitly associated with any other custom route table, and it can’t be deleted.

A subnet can have only one route table associated with it, while a route table can be associated with multiple subnets simultaneously.

Routes

Routes within a route table determine where the network traffic has to be routed from the resources within a subnet. Each route addresses two fields in a route table:

  • Destination: This specifies the range of IP addresses to which the route applies.

  • Target: This specifies the resource to which the traffic is directed for a particular destination.

For example, every route table contains a default route, also known as the local route, that can’t be modified or deleted. In a local route, the destination field is set to the VPC CIDR, and the target is set to local, which means that the network traffic originating for the VPC CIDR will be routed locally within the VPC. This allows all resources within the VPC subnets to communicate with each other.

Get hands-on with 1200+ tech skills courses.