VPC - Virtual Private Cloud

OSI model consists of 7 layer :


1. Physical layer - Raw bits transfered over cable via electrical signals.

2. Data link - Switches direct these electrical signals. They use MAC address to identify the next destination. 

3. Network layer - Routers receive frames from Data link layer and directs them to the destination based on the address defined in the frame. They use IP (Internet protocol) to identify the next destination. ICMP, ARP are example protocols work on this layer.

4. Transport layer - This layer manages delivery and error checking. TCP,UDP are the examples of protocols work on this layer.

5. Session layer - This layer controls communication between two computers. Netbios,PPTP is the one of the example works on this layer.

6. Presentation layer - This layer is responsible for encryption/decryption of data. SSL, TLS are examples.

7. Application layer - The final layer where user interacts. Example protocols : HTTP,SMTP, FTP etc.


So we can say that switches connect computers within a local area network (LAN), while routers are used to connect computers across wide area networks (WANs). Routers must know where they  have access and where they don't. That is why there is a table called router table that allows you to specify this.

CIDR notation :

192.168.0.0/24  -> means that IP address has mask of 24 bits. 

As we know that 1 byte equals 8 bits, so that we have 24 bits mask 255.255.255.0

This means that only the last digit can change rest are masked 

192.168. 0. X    -> only X can change, rest should stand still.

255.255.255.0




Let's create our own VPC, private and public subnets


  1. Type VPC in the searchbar





  2. Click to "Create VPC" to create one, this stage you have to choose one CIDR range for this VPC, this will be useful for subnet creation phase.






  3. Okay, now create subnet for this VPC, I will create 2 public and 2 private subnet for my VPC, you can create as much as you want. The most important thing at this phase is taking into consideration the subnet CIDRs. CIDR range for each subnet must align with the CIDR range of VPC and should not overlap with other subnets. 







  4. When we create EC2 instances in these subnets we want instances created for public subnets assigned to public IP address.




  5. Okay, now we need to create route table, to ensure that private subnets are isolated from rest. And we will create route table for public subnets as well to connect them to internet gateway.










  6. Need to create internet gateway to grant access public subnets to internet. By  default no subnet has internet access, we should grant them specifically. To do that internet gateway required.
     







  7. At the end all should look like this:



  8. So when we create EC2 instance we must edit network settings during EC2 setting phase and select our VPC and subnet accordingly.




  9. As a result when we connect our instances in the public subnet, we will be able to connect internet , but connecting to EC2 instances directly won't be possible due to no public IP address. But after connecting public instance since they are located in the same VPC we can SSH to private subnet instances too. 






   

Comments

Popular posts from this blog

Identity Access Management - How to create user in IAM ?!

EC2 - User data

IAM - Roles