Instead of using Virtual box machine, I am going to use cloud. The most important thing is VPC Which stands for Virtual Private Cloud. Inside of VPC, there’s smaller set of hosting resources that are available in AWS Datacenter which is called Availability Zone (AZ). Each zone in a region has redundant and separate power, networking and connectivity to reduce failing simultaneously. I can create subnet when I use AZ which is a range of IP addresses in your VPC. You can launch AWS resources, such as EC2 instances.
In order for my machine to be useful, this machine needs to be connected to internet. You need to have route and internet gateway. I am going to show the steps how to create VPC and EC2 instance and connect to the internet.
Create VPC
go to VPC > YourVPCs > Create VPC, and give a nice Name tag and choose IP block. This IP block should be private IP addresses according to rfc1918.
I’m going to choose 10.30.0.0/16 (You don’t need to pay for VPC)
Create Subnet
Next step is creating subnet. Go to VPC > Subnets > Create subnet, choose the VPC ID that you just created and Create Subnet
The IPv4 CIDR block needs to be within the block of my VPC network range, so I put 10.30.10.0/24. Click Create subnet if the subnet setting is done.
Create Internet Gateway
Go to VPC > Internet gateways > Create internet gateway and create the IGW.
Attach Internet gateway
Click your internet gateways and Actions, select Attach to your VPC. Make sure the state indicates Attached
Create Route Tables
Go to VPC > Route tables > Create route tables, follow below screenshot to create.
Subnet Associations
Click the Route table and Subnet association, then you will see your subnet is not associated yet. so you will want to edit subnet associations.
Add new Router
So far, new routes has been added to your routing table. This is the routes that connect to VPC. Next step is to add a new route that will connect to internet to the router using internet gateway. Click Edit routes and Add route.
Set the default route (0.0.0.0) that catches all the packet and send them internet gateway that we created earlier. Click save changes.
Create EC2 Instance
Switch to EC2 dashboard, and click launch instance.
Go to Configure Instance Details, select your VPC and Subnet and enable Auto-assign Public IP.
Click Review and Launch. Select a key pair or Create a new one if you don’t have existing key pair. (I have)
Connect to EC2 Instance
Click your EC2 instance and Connect. Copy the Example command