Creating a Custom VPC with Subnets, Route Tables & Internet Gateways.

Babajide Onamusi
3 min readFeb 20, 2023

--

Required: An AWS Account, Some Knowledge of Networking.

A few things to have in mind as you go through:

  • A VPC is a logically isolated portion of the AWS cloud within a region.
  • VPC Routers take care of the routing within the VPC and outside of the VPC.
  • A subnet is a segment of VPCs address range where you can place groups of isolated resources. it is created within the Availability Zone (AZ); it cannot span across AZs.
  • Route Table is used to configure the VPC router.
  • Internet Gateway is used for sending data out to the internet.

Enter into your AWS Console. Navigate to your VPC Terminal and select your VPCs.

CREATING A VPC

  • Select VPC only, Create a name tag, IPv4 CIDR Manual input, add the CIDR Block, Also select a Default Tenancy, and Create.
Creating a VPC instruction.

Once the VPC is created, go to the “actions” tab, select edit DNS hostnames and tick enable. “This ensures that we will get DNS hostnames for our EC2 instances”

CREATING SUBNETS

  • Select the subnets tab, navigate to create subnets, and specify the VPC. Select the availability zone close to you or where the clients will be. Then the CIDR block.
Public Subnets
Private Subnets

Note: The private and public subnets must use the same availability zones, i.e public_1 and private_1 use the eu-west-2a availability zone.

Next, highlight the Public VPCs and select the action tab, then navigate to the modify auto-assign settings, and enable auto-assign public IPv4 address.

CREATING PRIVATE ROUTE TABLES

  • Select the Route Tables tab, create route tables, name them, and select VPC.
  • Select the edit subnet associations tab and select the private VPCs.

Once that is done, navigate back into route tables and remain in the route table; Here it is “Main”.

CREATING AN INTERNET GATEWAY

  • Navigate to the Internet gate tab, create an internet gateway, and name it

Once created, it needs to be attached to a VPC. Select the actions tab, attach to VPC, and save.

  • Go to the Route Tables tab, select the main route, routes, and edit routes.
  • Add the “0.0.0/0” and the internet gateway. Save changes.

These settings ensure that everything within the CIDR block will be routed locally by the VPC router and anything outside that range will be routed through the internet gateway.

CONGRATULATIONS!!! You have created our Custom VPC with 2 public and Private subnets, route tables, and internet gateways.

--

--