Skip to content
Fixedmark

Cost · 11 min read

Updated

AWS NAT Gateway Alternatives for a Fixed Egress IP

The main alternatives to an AWS NAT gateway are a NAT instance (built by hand or from fck-nat), an egress-only internet gateway for IPv6, VPC endpoints for traffic to AWS services, and a static IP proxy. Only a NAT instance and a proxy give a partner a fixed IPv4 address to allowlist. The other two shrink or remove NAT traffic but give you no IPv4 address to hand over.

On this page

Two jobs a NAT gateway does

A NAT gateway in a public subnet does two separate things for the private subnets that route to it. It gives them outbound internet access over IPv4. It also makes every connection leave from the gateway's Elastic IP, which is the address you give a bank, a broker, or a partner API to allowlist.

Each alternative below replaces one job, both, or part of one. Decide which job you need first. If a payout API wants one fixed IPv4 address, you need the second job. If your containers only pull images from ECR and write to S3, you may not need a NAT path at all.

For the gateway's cost math, read the hidden costs of a NAT gateway and the AWS public IPv4 charge, or run your traffic through the NAT gateway cost calculator. In short, a gateway bills per hour in each AZ and per GB processed.

Every option here still pays standard AWS data transfer out to the internet. The savings come from the NAT gateway's hourly and processing charges, not from egress itself.

NAT instances: run the translation yourself

A NAT instance is an EC2 instance in a public subnet that forwards traffic for private subnets and masquerades it behind its own public address. Give it an Elastic IP and the partner sees that address. You pay for the instance and the address. There is no per-GB processing charge, because there is no managed service in the path.

AWS still documents this, with a warning. Its old NAT AMI is built on Amazon Linux AMI 2018.03, which reached end of maintenance support on December 31, 2023. AWS recommends a NAT gateway instead, and tells you to build your own NAT AMI from a current Amazon Linux if an instance fits better.

Build one by hand

The AWS setup guide uses AL2023 or Amazon Linux 2 with iptables. Run this on the instance, then save it as an AMI. Replace ens5 with the primary interface name that ip link shows.

On the NAT instance
sudo yum install iptables-services -y
sudo systemctl enable --now iptables

echo 'net.ipv4.ip_forward=1' | sudo tee /etc/sysctl.d/custom-ip-forwarding.conf
sudo sysctl -p /etc/sysctl.d/custom-ip-forwarding.conf

sudo /sbin/iptables -t nat -A POSTROUTING -o ens5 -j MASQUERADE
sudo /sbin/iptables -F FORWARD
sudo service iptables save

Then wire it into the VPC from your own machine. The instance must stop checking that it is the source or destination of every packet, or it drops forwarded traffic. The private route table then sends 0.0.0.0/0 to the instance.

Terminal
# Let the instance forward traffic that is not addressed to it
aws ec2 modify-instance-attribute \
  --instance-id i-0123456789abcdef0 --no-source-dest-check

# Pin the egress address partners will allowlist
aws ec2 associate-address \
  --instance-id i-0123456789abcdef0 --allocation-id eipalloc-0123456789abcdef0

# Send the private subnet's internet traffic to the instance
aws ec2 replace-route --route-table-id rtb-0private0a \
  --destination-cidr-block 0.0.0.0/0 --instance-id i-0123456789abcdef0

Use create-route if the table has no default route yet. The instance's security group must allow inbound traffic from the private subnets.

What you take on

AWS's comparison of NAT gateways and NAT instances is blunt about the trade.

NAT gateway and NAT instance, per the AWS comparison page
NAT gatewayNAT instance
AvailabilityRedundant within its AZ. One per AZ for zone independence.You script failover between instances.
BandwidthScales up to 100 GbpsWhatever the instance type gives
MaintenanceManaged by AWSYou patch the OS and the NAT software
Connection timeoutSends RST to the clientSends FIN to the client

Availability is the row that bites. One instance serving two AZs is a single point of failure for both, and traffic from the other AZ pays cross-AZ transfer to reach it. Mirror the gateway layout instead, with one instance and one Elastic IP per AZ. The partner allowlists two addresses, which is normal. See why one static IP is a single point of failure.

fck-nat and alterNAT

You do not have to build the AMI yourself. fck-nat is an MIT-licensed project that publishes ready NAT AMIs for arm64 and x86_64, built on Amazon Linux 2023. The AMIs are owned by account 568608671756 and named fck-nat-al2023-*. Its docs put a t4g.nano at $0.0042 an hour in US East, about $3 a month, with $0 per GB of NAT processing. Add the Elastic IP on top.

Find the latest fck-nat AMI in a Region
aws ec2 describe-images --region ap-south-1 \
  --owners 568608671756 \
  --filters 'Name=name,Values=fck-nat-al2023-*-arm64-ebs' \
  --query 'sort_by(Images, &CreationDate)[-1].[ImageId,Name]' \
  --output text

Size it for sustained traffic, not burst

The cheap price hides a bandwidth limit. fck-nat's instance sizing guide notes that burstable instances advertise "up to" figures. A t4g.nano bursts to 5 Gbps but sustains about 32 Mbps. A c6gn.medium sustains 1.6 Gbps, and a c7gn.medium sustains 3.125 Gbps. EC2 caps internet egress at 5 Gbps for instances under 32 vCPUs. If your workload moves steady bulk traffic, price the instance that sustains it, not the nano.

Busy NAT instances can also run out of connection tracking. fck-nat's configuration file, /etc/fck-nat.conf, has nf_conntrack_max and ip_local_port_range for that, alongside eip_id (the Elastic IP to attach at boot) and eni_id (the network interface for high availability mode).

High availability mode

In high availability mode, fck-nat runs one instance in an Auto Scaling group. A floating network interface stays in the route table, and each new instance attaches it at boot. If the instance dies, the group launches a replacement that picks up the same interface and, if you set one, the same Elastic IP. Without an Elastic IP, the replacement gets a new public address and your partner's allowlist breaks.

This is replacement, not hot standby. Egress from that AZ is down while a new instance boots, and open connections drop. fck-nat's docs point workloads that need very high uptime to the managed gateway.

The community Terraform module wires all of this up. It requires the AWS provider 6.0 or later. Use one module per AZ.

main.tf
resource "aws_eip" "egress_a" {
  domain = "vpc"
}

module "fck_nat_a" {
  source  = "RaJiska/fck-nat/aws"
  version = "1.6.1"

  name          = "egress-a"
  vpc_id        = aws_vpc.main.id
  subnet_id     = aws_subnet.public_a.id
  instance_type = "t4g.nano"

  ha_mode            = true
  eip_allocation_ids = [aws_eip.egress_a.id]

  update_route_tables = true
  route_tables_ids = {
    private-a = aws_route_table.private_a.id
  }
}

The module accepts at most one Elastic IP per instance, and it defaults to t4g.micro if you leave out instance_type. Repeat the block for public_b and private_b with a second Elastic IP.

alterNAT

alterNAT, from Chime, pairs each AZ's NAT instance with a standby NAT gateway. A Lambda function checks connectivity every minute and, on failure or replacement, points the route table at the standby. Its README pitches it at high volumes, around 10 TB a month. Two things matter for an allowlist. The standby gateways bill by the hour even when idle, and they have their own Elastic IPs, so the partner must allowlist the instance addresses and the gateway addresses.

IPv6 and the egress-only internet gateway

An egress-only internet gateway is the IPv6 counterpart of a NAT gateway's outbound-only behaviour. It lets resources start connections to the internet over IPv6 and blocks connections started from outside. AWS charges nothing for the gateway itself, only normal data transfer. It is stateful, scales on its own, and needs no instance.

Terminal
aws ec2 create-egress-only-internet-gateway --vpc-id vpc-0123456789abcdef0

aws ec2 create-route --route-table-id rtb-0private0a \
  --destination-ipv6-cidr-block ::/0 \
  --egress-only-internet-gateway-id eigw-0123456789abcdef0

Lambda can use it. A VPC-attached function sends outbound IPv6 when every subnet it uses is dual-stack and you turn on Ipv6AllowedForDualStack. Lambda does not support outbound IPv6 from IPv6-only subnets, or from functions that are not attached to a VPC.

Terminal
aws lambda update-function-configuration --function-name payouts \
  --vpc-config Ipv6AllowedForDualStack=true,SubnetIds=subnet-0aaa1111,subnet-0bbb2222,SecurityGroupIds=sg-0ccc3333

What this does and does not fix

IPv6 traffic through the gateway is not translated. The source address is the resource's own IPv6 address, from the subnet's /64, which belongs to your VPC. A partner that accepts IPv6 can allowlist that prefix, and nobody outside your VPC sends from it. That is a stronger allowlist than a cloud's shared ranges, which admit every tenant (see why cloud IP ranges are not an allowlist).

The catch is the other side. Most of the allowlists people need a static IP for, such as Indian broker consoles, bank API onboarding forms, and payout dashboards, usually take IPv4 only. An IPv4-only destination still needs an IPv4 path. The AWS way to reach IPv4 from IPv6-only subnets is DNS64 and NAT64, and NAT64 runs on a NAT gateway, so you are back to paying for one. Since version 1.4, fck-nat also builds fck-nat-nat64-* AMIs that do NAT64 on an instance.

So the egress-only gateway is a cost tool, not a static IP tool. In dual-stack subnets, IPv6-capable destinations go through the free gateway and only IPv4 takes the NAT path. Which one a client picks depends on DNS and the client, as IPv6 egress and IPv4-only allowlists covers.

VPC endpoints: take AWS traffic off the NAT path

A lot of NAT traffic never leaves AWS. Image pulls from ECR, S3 writes, and DynamoDB reads from a private subnet cross the NAT gateway and pay its processing charge unless an endpoint sends them to the service directly.

  • Gateway endpoints exist for S3 and DynamoDB only. They add a prefix-list route to the route tables you pick, and AWS charges nothing extra for them. For an S3-heavy workload this is the cheapest fix there is.
  • Interface endpoints (PrivateLink) cover most other AWS services. They bill per endpoint per AZ per hour and per GB processed. The PrivateLink pricing page uses $0.01 an hour per endpoint interface and $0.01 per GB for the first petabyte in its US East example. Add them for high-volume services only, since several across three AZs can cost more than they save.
Terminal
aws ec2 create-vpc-endpoint --vpc-id vpc-0123456789abcdef0 \
  --vpc-endpoint-type Gateway \
  --service-name com.amazonaws.ap-south-1.s3 \
  --route-table-ids rtb-0private0a rtb-0private0b

Endpoints give you no address to hand a partner. They also change how AWS-side allowlists work. Per the IAM condition key reference, aws:SourceIp is not in the request context when a request arrives through a VPC endpoint. A bucket policy that allowlists your NAT gateway's Elastic IP stops matching for same-Region buckets once you add an S3 gateway endpoint. Rewrite those policies with aws:SourceVpce or aws:SourceVpc before you add the endpoint, not after.

A static IP proxy instead of NAT

NAT catches every packet from the subnet. A proxy works per connection. Your code sends only the calls that need a fixed address, such as a bank API, through a proxy whose IPs are allowlisted. How an HTTP CONNECT proxy works explains the protocol. TLS runs end to end, so the proxy forwards encrypted bytes.

It also works anywhere. A NAT instance or gateway only serves subnets in its own VPC. A proxy serves any client that can open an outbound TCP connection, including a Lambda function with no VPC at all. That function's own egress IP keeps changing (see why serverless egress IPs change), but the partner never sees it.

// npm install undici
import { fetch, ProxyAgent } from "undici";

// Created once at init, reused across warm invocations.
const proxy = new ProxyAgent(process.env.EGRESS_PROXY_URL);

export const handler = async () => {
  // Only this call goes through the proxy. AWS SDK calls go direct.
  const res = await fetch("https://api.partner.example/v1/payouts", {
    dispatcher: proxy,
  });
  return { statusCode: res.status, body: await res.text() };
};

Use a dedicated variable name rather than HTTPS_PROXY. boto3 reads HTTPS_PROXY, so setting it on the function sends AWS API calls through the proxy too. Selective proxying with NO_PROXY and per-client agents covers how each runtime treats those variables.

Self-hosted or managed

You can run Squid or a similar forward proxy on an EC2 instance with an Elastic IP. Your callers' addresses change, so the proxy needs authentication, sent over TLS. Failover means two instances in two AZs, which is the NAT instance problem plus one more application to patch.

A managed proxy moves that work to a provider for a flat plan price.

A proxy does not remove the NAT path for compute that lives in private subnets. That compute still needs some internet route to reach the proxy. The proxy only frees that route from having to be stable or known to the partner.

Choosing between them

NAT gateway alternatives for fixed egress, by what they give a partner and what they cost you
OptionFixed IPv4 for a partnerAvailabilityYour upkeepCost shape
NAT gateway (baseline)Yes, one Elastic IP per gatewayManaged, one per AZNoneHourly per AZ plus per GB processed
NAT instance, built by handYes, with an Elastic IPWhatever you scriptAMI, OS patches, failoverInstance hours, no per-GB processing
fck-natYes, with eip_allocation_idsAuto Scaling replacement, connections dropAMI updates, sizingFrom $0.0042 an hour for a t4g.nano in US East
alterNATYes, but allowlist instance and standby gateway IPsFails over to a standby NAT gatewayTerraform module, LambdaInstance hours plus standby gateway hours
Egress-only internet gatewayNo. IPv6 prefix onlyManagedNoneNo gateway charge
VPC endpointsNo. AWS services onlyManagedEndpoint policiesGateway type free, interface type hourly per AZ plus per GB
Static IP proxyYes, the proxy's IPsTwo proxy hosts, yours or the provider'sSelf-hosted: all of it. Managed: client configInstance hours, or a flat plan

These options combine. A sensible layout is gateway endpoints for S3 and DynamoDB in every VPC, dual-stack subnets with an egress-only gateway, and then one of the IPv4 options for what is left. Pick that last piece by what the partner needs and how much traffic remains.

  • Many workloads in private subnets, heavy general egress, and nobody to patch instances. Keep the NAT gateway and cut its traffic with endpoints and IPv6.
  • Lots of traffic, cost pressure, and someone who owns the network. fck-nat per AZ, with Elastic IPs and the instance sized for sustained throughput.
  • Only a few calls need a fixed IP, or the code runs outside AWS, or across several platforms. A static IP proxy, with no NAT needed for that purpose.

Whichever you choose, run curl https://checkip.amazonaws.com from each subnet before you send addresses to the partner. A route table still pointing at an old gateway is a common reason one AZ gets rejected. On Kubernetes, see static egress IPs on Kubernetes.

Doing this with Fixedmark

Fixedmark is a managed static IP proxy, in early access. In the code above, set EGRESS_PROXY_URL to your Fixedmark proxy URL, such as https://APP_ID:TOKEN@mum.egress.fixedmark.com:443, and pass it only to the clients that call allowlisted APIs. The partner allowlists a pair of static IPv4 addresses that Fixedmark holds in Mumbai, Singapore, Newark, or Ashburn, so a payout call from Lambda in ap-south-1 can leave from Mumbai.

  • The proxy URL is HTTP CONNECT over TLS on port 443, or SOCKS5 over TLS on port 1443 for databases and other TCP services. TLS to the destination passes through and is never decrypted. See concepts and the Node.js and Python guides.
  • A Lambda function outside a VPC can use it with no subnets or routes. See the AWS Lambda guide. AWS still bills data transfer out to the proxy.
  • The planned launch price for a dedicated IP pair is $29 a month on Pro, with 100 GB of bandwidth, and may change. The NAT gateway comparison sets it beside a two-AZ gateway.
  • The trial runs on a shared IP pair, so do not register its addresses with a bank or broker. Confirm the address with Verify your egress IP before you hand it over.

It does not replace NAT for a VPC full of workloads that need general internet access. For heavy, all-protocol egress from private subnets, a NAT gateway or fck-nat fits better.

Sources

Checked November 2026. Confirm current details on the vendor's site before you decide. Prices and limits change.

Blog

Frequently asked questions

Is fck-nat safe to use in production?

It is an open-source NAT AMI on Amazon Linux 2023, and its docs are clear about its limits. The risks are the ones of any NAT instance. A failure takes egress down until the Auto Scaling group replaces the instance, open connections drop, and you own AMI updates. Use an Elastic IP so the address survives replacement, and run one instance per AZ.

Does a NAT instance keep the same IP after it is replaced?

Only if you attach an Elastic IP. An auto-assigned public IPv4 address is released when the instance stops or terminates, and the replacement gets a new one. fck-nat attaches the Elastic IP you give it at boot, through `eip_id` in its config or `eip_allocation_ids` in the Terraform module.

Can an egress-only internet gateway replace a NAT gateway?

Only for IPv6 traffic. It is free and managed, but it carries no IPv4. If any destination is IPv4-only, as many partner allowlists are, you still need a NAT gateway, a NAT instance, or a proxy for those calls.

Do VPC endpoints give me a static IP?

No. They route traffic to AWS services privately, which cuts NAT processing charges. Requests through an endpoint carry no `aws:SourceIp`, so AWS-side policies should match on `aws:SourceVpce` or `aws:SourceVpc` instead of your NAT address.

Make it fixed.

Fixedmark is in early access. Join the list to get dedicated static IPs when your region opens.