int128 / terraform-aws-nat-instance

Terraform module to provision a NAT Instance using an Auto Scaling Group and Spot Instance from $1/month
https://registry.terraform.io/modules/int128/nat-instance/aws/
Apache License 2.0
175 stars 90 forks source link

Use eth0 for output #52

Open JulianCBC opened 2 years ago

JulianCBC commented 2 years ago

The only requirement for NAT to work is a functional internet connection, so as the NAT EC2 instance is running on a public subnet, we don't actually need a EIP to get a public IP and therefore an internet connection. (Also they're a very limited resource to be required by a "cheap" NAT solution)

Update the SNAT scripting to use eth0 for the upstream internet connection instead of deconfiguring it.

I haven't tested DNAT port forwarding with this, but it should still work as it did before once an EIP is connected to the "floating" eth1 interface as Linux's routing shouldn't care.

Upgrading to this set of changes will break any system that expects to have an open port on the same IP as it sends from. The fix is to update the DNAT rules to use eth0 instead of eth1.

This depends on #51.