Friday 11 August 2017

thumbnail

How to create AWS VPC, Subet, Route Table and Internet Gateway in AWS

Introduction


Amazon Virtual Private Cloud (Amazon VPC) lets you provision a logically isolated section of the Amazon Web Services (AWS) cloud where you can launch AWS resources in a virtual network that you define. You have complete control over your virtual networking environment, including selection of your own IP address range, creation of subnets, and configuration of route tables and network gateways.  You can use both IPv4 and IPv6 in your VPC for secure and easy access to resources and applications.


You can easily customize the network configuration for your Amazon Virtual Private Cloud. For example, you can create a public-facing subnet for your webservers that has access to the Internet, and place your backend systems such as databases or application servers in a private-facing subnet with no Internet access. You can leverage multiple layers of security, including security groups and network access control lists, to help control access to Amazon EC2 instances in each subnet.

Additionally, you can create a Hardware Virtual Private Network (VPN) connection between your corporate datacenter and your VPC and leverage the AWS cloud as an extension of your corporate datacenter.

In this tutorial we will create one public subnet and one private subnet in the same Region and we will attach the public subnet to the internet gateway.  We will also try connect public instance from private instance using SSH.

1. Lets the Create the VPC.



Click on Your VPC in the left hand side and Click Create VPC



2. Now create a Subnet Like below :-

First we will create Public Subnet like below 



Give the name and assign IP like below :-



By default subnet will come one Route Table created.





Private Subnet like below :-



We have create our both Subnet Public and Private 



3. Now we want our Public Subnet to have internet access for that we have to create Route Tables. One route table is already created while we created the Subnet. We have to create one for  private  subnet. 




4. We have to Create one Internet Gateway and Attach to our VPC.






5. Now we have to configure our route tables so that only public route table will only get the internet access and we have to remove the internet access from the private one by attaching the route table to the subnet.

Go to Subnet and Select Public Subnet and Click Route Table like 



Now add the route to the Internet-Gateway which we created

After Selecting the Route table click on Edit and "Add another rule" dont remove the default one.



Now remove the internet access from Private Subnet 

Go to Subnet and select Private Subnet and Edit Route to Private Route table.



To change Click on Edit and Select from drop down to Private.
 

Lastly we need to enable Auto Assign Public IP to our Public subnet and also we need to enable DNS hostname.  



Now enable DNS-hostname




Now we will test it by creating EC2-Instance within our VPC.

Select your VPC and subnet while creating your instance



As you can see in the below images the IP address has been assigned to the instance 



Configure the security Group so that we do SSH to our instance by allow SSH and ICMP .



 Try to do SSH from terminal



As you can see in the above image we have got our public subnet IP.

Now launch the instance with private subnet and we will try to connect from Public instance.



 And configure the security group like below in Private instance.


As you can see in the above image we have not the public IP as well as DNS hostname.


 Now try to connect with terminal using Telnet and ping test it.




 Now I have transferred my keys to Public instance and then tried to connect using SSH like below :-

1. Enable the password authentication in SSH of Public Instance:-

2. Transfer the keys to Public instance.

scp -r abcd.pem ec2-user@34.213.41.47:

3. Do ssh to private instance :-

ssh -i abcd.pem ec2-user@192.168.20.108

Then you will be presented with the following screen.


That's it now 
You have successfully created your VPC
Please do Comment, Likes and Share
Tags :

Subscribe by Email

Follow Updates Articles from This Blog via Email

No Comments