Three ways to keep an EC2 reachable, and why DDNS barely saves money now

2024/10/07
awsec2networkingroute53

You launch an EC2 and AWS hands it a public IP. You point a DNS record at it and get to work. Then you stop the box overnight to save money, start it in the morning, and the IP is different. Every link to the old one breaks.

The auto IP is dynamic. To stay reachable you need an address that doesn't move. Three ways.

1. Auto-assigned public IP

No setup, but AWS releases it on every stop and assigns a new one on start. Fine for a throwaway box, useless for anything you need to find again.

2. Elastic IP

A fixed address tied to your account. Attach it once, point an A record at it, done. It survives restarts.

It used to be free while attached. Not anymore: since February 1, 2024, every public IPv4 address costs 0.005 USD an hour (about 3.6 USD a month), in use or not, and the VPC pricing page still lists that price. So an Elastic IP is a small, fixed line item. Release ones you're not using, or you're paying for nothing.

If your account was created before July 15, 2025, the free tier covers 750 hours of public IPv4 a month for the first 12 months, enough for one address running all month. Newer accounts get a 100 USD sign-up credit instead, valid for six months or until it runs out. For those accounts the EC2 free tier page no longer lists the 750 hours, and it doesn't say whether the credit covers public IPv4.

3. DDNS

Keep the dynamic IP, put a name in front. A small client on the instance loops over two steps:

  1. ask "what's my public IP right now?" (the OS only sees the private IP because the internet gateway NATs it, so the client asks an outside service or the instance metadata endpoint),
  2. if it changed, tell a DNS provider to re-point the name at the new IP.

You don't write this client yourself. DDNS providers usually ship one, such as No-IP's DUC (Dynamic Update Client). If you'd rather not tie it to one provider, the open-source ddclient supports most of them; on Ubuntu, apt install ddclient. For No-IP, a config based on ddclient's sample file looks roughly like this:

# /etc/ddclient.conf
daemon=300                                 # check every 300 seconds
use=web, web=checkip.dyndns.org/, web-skip='IP Address'   # ask an outside service for the public IP
protocol=noip, ssl=yes, server=dynupdate.no-ip.com
login=your-noip-login, password=your-noip-password
myserver.ddns.net

So myserver.ddns.net finds the box again after the IP flips from 54.201.13.7 to 3.88.42.190, once cached DNS expires. You connect to the name; the client chases the IP.

Already own a domain? If its DNS host has no update API, the client can't update it directly: Squarespace Domains, for example, dropped the dynamic DNS that Google Domains had. So get a free DDNS hostname and bridge to it with one CNAME, set once and never touched again:

your.domain.com  ──CNAME──►  myserver.ddns.net  ──(DDNS keeps current)──►  the live IP

The catch. DDNS used to be the cheap option, because the auto IP it rides on was free. After the 2024 change that IP costs the same 0.005 USD an hour as an Elastic IP while the box runs. The only saving left is the stopped hours: the auto IP is released on stop and billed nothing, while an Elastic IP is billed whether attached or not. Stopped 12 hours a night, that is about 1.8 USD a month. For that, you trade a fixed IP for a free name plus a client to babysit.

What about IPv6?

The EC2 docs say an instance keeps its IPv6 address across stop and start, and releases it only on terminate. The VPC pricing page bills public IPv4 and lists no charge for IPv6. So if the instance has an IPv6 address, point an AAAA record at it and it still works after a restart.

The VPC and subnet need an IPv6 CIDR associated first, or the instance gets no IPv6 address. The route table needs a ::/0 → igw route, and the security group has to allow IPv6 sources.

A user on an IPv4-only network can't reach an IPv6-only instance. Keep a public IPv4 for them and that address is billed by the hour and changes on stop/start, same as before.

Where Route 53 fits

An A record maps a name to a fixed IP (app.mysite.com → 54.201.13.7). A Route 53 alias maps a name to an AWS resource (ELB, CloudFront) and tracks its shifting IPs for you (alias targets are AWS resources, not a raw EC2).

So with an Elastic IP, use a plain A record; it never moves. A bare EC2 has no alias target, so it only gets an A record to its IP, which is exactly why it wants a fixed one. And if an ELB, or CloudFront with a VPC origin, sits in front, alias your domain to that and drop the Elastic IP entirely; AWS tracks the IPs.

The takeaway

A public IP isn't free just because it's attached; since 2024 every one is metered. So choose mostly by simplicity: a fixed Elastic IP for anything real, an ELB in front if you'll pay more to forget IPs, and DDNS only for hobby boxes that sit stopped often enough for a free name to be worth babysitting a client. IPv6 gives a fixed address with no IP charge, but only users with IPv6 can reach it.

References