Project Ferris

AWS Nat Server

ยท 388 words ยท 2 minutes to read

Why Build This? ๐Ÿ”—

AWS has NAT Gateways which are easy to set up in just a few clicks. This simplicity comes at a cost. AWS NAT Gateways have a significant cost depending on workload. At the time of writing AWS NAT Gateway cost $0.045 an hour. $0.045 * 730 hours = $32.85 a month. That is the cost of a NAT Gateway doing nothing a month. AWS also charges based on how much data goes through a NAT Gateway. According to their website there is $0.045 fee for data processed by the NAT Gateway. That includes data received by the NAT Gateway. This can result in unexpected high data transfer bills. Data transfer pricing gets very complicated. Having a NAT Gateway can result in you paying data transfer costs for data going through the NAT Gateway and then another cost for that same data to go through an Internet Gateway. Then you need to take into account the return traffic won’t have a Internet Gateway cost but it will have a NAT Gateway data transfer cost. There is also almost no configurability of a NAT Gateway. This is why you may want a NAT Server. This example is a very basic example running on a very small EC2 instance.

The Solution ๐Ÿ”—

Design

Create a EC2 instance with the specs your use case needs and configure it with NAT. This effectively is the same thing as the NAT Gateway. The only difference is now you have more control over the settings. For example, if you wanted to configure port forwarding you can now configure that. If you do not need to send much traffic you can keep the instance type small. If you need to handle larger amounts of traffic you can increase the instance type.

Below is what you will see in the EC2 Console if you deploy the Terraform provided at the bottom of this page. Servers

Below are the key details about the NAT Servers NAT Server Details

Below are the key details about the Test Servers Test Server Details

Below is a traceroute from the Test Server. You can see the traffic go to the NAT Server and then to the internet. Test Server Traceroute

The Terraform source code which can deploy this configuration can be found here: https://github.com/Craigspaz/AWSNATServer

Note: This was created for experimental purposes and should not be used in a production environment

Categories


Tags