Sunday, March 20, 2022

AWS Networking & Content Delivery - VPC Natgateway and Elastic IP for private subnet


To c
heck internet connectivity is available for Private VM (ping 8.8.8.8), you will need to establish a NAT gateway.

NAT Gateway 

A NAT gateway is a Network Address Translation (NAT) service. You can use a NAT gateway so that instances in a private subnet can connect to services outside your VPC but external services cannot initiate a connection with those instances.


Creating a NAT Gateway

1. Click on create a NAT (Network Address Translation) Gateway

2. Select Public Subnet 1-a

3. Connectivity type: Public

4. Click on Allocate Elastic IP button

5. Click on the Nat Gateway

6. It takes some time to create, once it is created select it and Go to Action --> Attach to VPC

7. Click on Route Table and Select private Route table

8. Select Routes --> Edit Route

9. Click on Add Route , Destination 0.0.0.0/0 and Target NAT Gateway and Click on save changes.

10. Now the private VM should have internet connectivity.


to connect to the private VM:

go to the public VM and connect into it.

then follow this steps on the public VM:


you should now be able to connect to the private VM via the public VM cause NatGateway is established.


Check if the private VM has internet connection:

after connecting to the private VM, use the curl command.


Experiments

1.  Delete NAT Gateway, Check if the EIP also get deleted.

Ans: EIP did not get deleted.

2. Find the EIP address allocated to NAT Gateway.

Ans: under the Elastic IP tab

3. How to delete a VPC.

Ans: delete any instances and any network interfaces.



# Actually just terminate the instances and the network interface will auto delete by themselves. now you can delete your VPC.


No comments:

Post a Comment

Fluentd

Open-source log data collector > why logs? - for compliance (auditing, company, business) - for security (transparency, monitoring, admin...