What is AWS Internet Gateway and How to Create it?-DecodingDevOps

What is AWS Internet Gateway and How to Create it?-DecodingDevOps

AWS Internet Gateway

An Internet Gateway is a  VPC component that is a highly available component that allows the instance in the VPC to communicate to the internet. 

Two purposes of Internet Gateway:

  1. Provides a target to route internet routable traffic
  2. Performs NAT translation

It supports IPv4 and IPv6 traffic.

You can create only one Internet Gateway per VPC.

How To Create Internet Gateway

  • Create an Internet Gateway
  • Attach it to VPC
  • Add route in your subnet’s route table to point to the internet
  • Your instance must need a publicly routable IP
  • Make sure that your NACLs and SGs allows the traffic to the internet

what is internet gateway in aws

In order to route the internet routable traffic to the internet you must create a route in the route table to point 0.0.0.0/0 to the IGW (allows IPv4 traffic) and ::/0 to point to the IGW (allows IPv6 traffic).

For routing Internet traffic from the instance which doesn’t have public IP, you can use NAT gateway.

Steps to Create VPC with Internet Gateway

Checklist:

  1. Create a subnet
  2. Create an Internet Gateway
  3. Attaching Internet Gateway to VPC
  4. Creating a custom route table
  5. Creating a Security Group
  6. Adding Elastic IP

Creating a subnet

  1. Open VPC console
  2. In the navigation pane, Go to Subnets
  3. Choose Create Subnet
  4. Specify VPC, AZ, CIDR Range, For IPv6 choose a custom range
  5. Select Yes, Create

Creating Internet Gateway

  1. Open VPC Console
  2. In the navigation pane, Go to Internet Gateway
  3. Choose Internet Gateway
  4. Specify IGW name
  5. Choose Create

Attach IGW to VPC

  1. Select the IGW and Choose on Action
  2. Choose Attach to VPC
  3. Select the VPC, choose Attach

Creating a custom route table

    1. Open VPC console
    2. In navigation pane, Choose Route Table
    3. Choose Create Route Table
    4. Specifty Name and VPC
    5. Choose Yes, Create
    6. Select Route table you just created, select the Route tab -> Edit -> Add Another Rule. Add 2 rules as below
      1. 0.0.0.0/0 -> Select IGW you created as the Target
      2. ::/0 -> Select IGW you created as the Target
    7. Choose Save
  • Subnet Association Tab -> Edit -> Associate -> Select the Subnet -> Choose Save

Creating a Security Group

  1. Open VPC Console
  2. In navigation pane, Select Security Groups
  3. Choose Create Security Group
  4. Specify Name and VPC
  5. Choose Yes, Create
  6. Select Security Group and Choose Inbound Rules
  7. Choose Edit -> Add Rule -> Choose the Required Traffic
  8. Choose Save

Now Lets attach this SG  to ec2 instance

  1. In navigation, Choose Instances
  2. Select the Instance, Choose Action -> Networking -> Change Security Groups to select New SG or Choose Assign Security Group

Adding Elastic IP

  1. Open VPC Console
  2. In navigtion pane, Choose Elastic IP
  3. Choose Allocate Address
  4. Choose Allocate
  5. Select the IP,  Choose Action -> Associate Address
  6. Specify Instance/Network Interface
  7. Choose Associate