Home

Configuring an Amazon VPC

Project Overview

Reflecting on my experience of configuring an Amazon Virtual Private Cloud (VPC) within the Amazon Web Services (AWS) environment, here's a detailed, step-by-step account of how I successfully completed each task, including relevant side notes for clarity.

Task 1: Creating a VPC

Step 1: Accessing the VPC Management Console

Step 2: Creating a New VPC

Step 3: Editing VPC Settings

Note: EC2 instances launched into the VPC now automatically receive a public IPv4 Domain Name System (DNS) hostname.

Task 2: Creating Subnets

Task 2.1: Creating a Public Subnet

Step 1: Accessing the Subnets Section

Step 2: Creating the Public Subnet

Step 3: Enabling Auto-Assign Public IP

Note: Even though this subnet has been named Public Subnet, it is not yet public. A public subnet must have an internet gateway, which I attached in a later task.

Task 2.2: Creating a Private Subnet

Step 1: Repeating the Steps for Creating a Subnet

Note: The CIDR block of 10.0.2.0/23 includes all IP addresses that start with 10.0.2.x and 10.0.3.x. This range is twice as large as the public subnet because most resources should be kept in private subnets unless they specifically need to be accessible from the internet.

Task 3: Creating an Internet Gateway

Step 1: Accessing the Internet Gateways Section

Step 2: Creating the Internet Gateway

Step 3: Attaching the Internet Gateway to the VPC

Note: Your public subnet now has a connection to the internet. However, to route traffic to the internet, you must also configure the public subnet's route table so that it uses the internet gateway.

Task 4: Configuring Route Tables

Step 1: Accessing the Route Tables Section

Step 2: Renaming the Existing Route Table

Note: There is currently only one route, which shows that all traffic destined for 10.0.0.0/16 (the range of the Lab VPC) will be routed locally. This option allows all subnets within a VPC to communicate with each other.

Step 3: Creating a Public Route Table

Step 4: Associating the Public Route Table with the Public Subnet

Note: The public subnet is now public because it has a route table entry that sends traffic to the internet through the internet gateway.

Task 5: Launching a Bastion Server

Step 1: Accessing the EC2 Management Console

Step 2: Launching the Bastion Server

Note: A bastion server (also known as a jump box) is an EC2 instance in a public subnet that is securely configured to provide access to resources in a private subnet. Systems operators can connect to the bastion server and then jump into resources in the private subnet.

Task 6: Creating a NAT Gateway

Step 1: Accessing the NAT Gateways Section

Step 2: Creating the NAT Gateway

Step 3: Configuring the Private Subnet Route Table

Note: Resources in the private subnet that wish to communicate with the internet now have their network traffic directed to the NAT gateway, which forwards the request to the internet. Responses flow through the NAT gateway back to the private subnet.

By following these steps, I successfully configured a robust VPC with public and private subnets, an Internet Gateway, appropriate route tables, a bastion server, and a NAT Gateway. Each task built upon the previous one, culminating in a fully functional and secure virtual network. This thorough and methodical process provided me with a comprehensive understanding of AWS networking and its critical components.

Testing the Private Subnet

Task: Launching an Instance in the Private Subnet

Step 1: Launching the Instance

#!/bin/bash
# Turn on password authentication for lab challenge
echo 'lab-password' | passwd ec2-user --stdin
sed -i 's|[#]*PasswordAuthentication no|PasswordAuthentication yes|g' /etc/ssh/sshd_config
systemctl restart sshd.service

Note: This script permits login by using a password. It is included to help make the lab steps shorter but is not recommended for normal instance deployments.

Task: Logging in to the Bastion Server

Step 1: Accessing the EC2 Management Console

Step 2: Connecting to the Bastion Server

Note: If preferred, an SSH client could be used to connect to the EC2 instance by following the guidance to Connect to Your Linux Instance.

AWS Management Console, I entered and chose "EC2" in the Search bar to open the EC2 Management Console.

Step 2: Connecting to the Bastion Server

In the navigation pane, I selected "Instances."

From the list of instances, I selected the "Bastion Server" instance.

Chose "Connect."

On the EC2 Instance Connect tab, I chose "Connect."

Note: If preferred, an SSH client could be used to connect to the EC2 instance by following the guidance to Connect to Your Linux Instance.

Task: Logging in to the Private Instance

Step 1: Copying the Private Instance IP Address

Note: This IP address is a private IP address starting with 10.0.2.x or 10.0.3.x. This address is not reachable directly from the internet, which is why logging in to the bastion server was necessary first.

Step 2: Connecting to the Private Instance

ssh PRIVATE-IP

Note: I should now be connected to the private instance. This task was accomplished by first connecting to the bastion server (in the public subnet) and then connecting to the private instance (in the private subnet).

Task: Testing the NAT Gateway

Step 1: Confirming Internet Access

ping -c 3 amazon.com

PING amazon.com (176.32.98.166) 56(84) bytes of data.
64 bytes from 176.32.98.166 (176.32.98.166): icmp_seq=1 ttl=222 time=79.2 ms
64 bytes from 176.32.98.166 (176.32.98.166): icmp_seq=2 ttl=222 time=79.2 ms
64 bytes from 176.32.98.166 (176.32.98.166): icmp_seq=3 ttl=222 time=79.0 ms

Note: This output indicated that the private instance successfully communicated with amazon.comon the internet. The private instance was in the private subnet, and the only way this was possible in the current scenario was by going through the NAT gateway. This output confirmed that my network configuration was successful.

Conclusion

I successfully completed the following:

This thorough process provided me with practical insights into AWS networking and validated my configurations in a secure and controlled environment.

Related Topics