Recently I've been preparing the SNAPCAM AWS environment for launch. One of the tasks on my todo list was to change the default VPC NAT instance for a better instance type.
When creating a simple public/private VPC using the VPC Wizard, AWS will create a NAT instance which instances in private subnets use to communicate with the public Internet. This default instance will be an
m1.small instance which, as demonstrated in this article, is poor both in it's networking capability as well as it's bandwidth (MBps) cost.
t2.small install provides adequate bandwidth for its price relative to our current needs. After a bit of trial and error, here's the final steps I performed for setting up this new NAT instance:
- First I created a new
t2.small instance using
ami-14913f63; this AMI is built by Amazon specifically for NAT boxes and is new enough to support the
t2 instance types. I didn't associate an IAM role, SSH key pair or public IP address.
- When the instance had launched I disabled destination source checking on the instance.
- NAT traffic is routed through the network interface of the instance so I noted the new instance's
eth0 identifier, for me this is
- In the VPC control panel, I went to Route Tables on the left-hand menu, then selected the private route table.
- Under Routes, I altered the
0.0.0.0/0 destination to target to the network interface identifier.
- The old NAT instance has an elastic IP address which I reassigned to my new NAT instance.
- Finally I rebooted all of the instances in the VPC's private subnets.
Image credit: https://www.flickr.com/photos/npobre/8437956869/