Create Routing Table On Cloud Using CLI On Windows
We can create routing tables and routing rules in AWS using CLI as well as attach route tables. In a similar way, we can have a route table in our VPC network AWS, and Let’s see, how to make and create a routing table. so
We have already created VPC and subnets. If you don’t know about it, you can check here how to create VPC and Subnets. so
Now create a route Table using CLI.
C:\Users\pankaj>aws ec2 create-route-table –vpc-id vpc-0458a0c7f45566cc4
Now we haven’t assigned a name to our route table. So, we need to run the below command. You can find the route table id as shown in the above figure “RouteTableId”: “rtb-07068a9a0f0bfd990“.
C:\Users\pankaj>aws ec2 create-tags –tags Key=Name,Value=MyRoute –resources rtb-07068a9a0f0bfd990
Verify on AWS Cloud
As you can see tag has assigned to a routing table.
An associate routing table with subnets:
The next step is to associate the routing table to subnets using the below command.
C:\Users\pankaj>aws ec2 associate-route-table –route-table-id rtb-07068a9a0f0bfd990 –subnet-id subnet-0e990d337f526a200
You will see a default route with 10.0.0.0/16 that’s automatically created by AWS.
We can also check whether it’s associated or not with the routing table.
If you require to attach the Internet gateway to the routing table. You have to create an internet gateway using the below command.
C:\Users\pankaj>aws ec2 create-internet-gateway
Once it’s created, we have to attach it to the VPC network.
C:\Users\pankaj>aws ec2 attach-internet-gateway –vpc-id vpc-0458a0c7f45566cc4 –internet-gateway-id igw-02dcdf4f0d2de9e84
Then we can attach it to the routing table with the below commands. If you see the output like this means you have attached it to the routing table. We have to add 0.0.0.0/0 network to subnet route tables because if you want to allow your subnets to access the internet So it will go out through the IGW.
C:\Users\pankaj>aws ec2 create-route –route-table-id rtb-07068a9a0f0bfd990 –destination-cidr-block 0.0.0.0/0 –gateway-id igw-02dcdf4f0d2de9e84
Now we will verify on AWS routing tables.
You’re done Aws routing rules attach route table aws