Home AWSHow to Set Up Route 53 DNS and an Elastic IP for Your EC2 Website

How to Set Up Route 53 DNS and an Elastic IP for Your EC2 Website

by Knowledge Base Linux
How to Set Up Route 53 — How to Set Up Route 53 DNS and an Elastic IP for Your EC2 Website

Setting up route 53 elastic ip ec2 correctly is the step that turns a temporary cloud server into a real, reachable website. If you launched an EC2 instance and its public IP changed after a stop and start, visitors could no longer reach your site, search engines pointed to the wrong address, and SSL certificates failed validation. This guide solves that problem permanently. You will allocate a static Elastic IP, associate it with your EC2 instance, create a Route 53 hosted zone, and add DNS records that point your domain to that stable address, then verify everything with practical propagation checks. This article covers How to Set Up Route 53 in detail.

If you have not launched a server yet, start with our guide on how to launch your first EC2 instance on AWS, then return here. You can also browse more guides in our AWS category.

Why Route 53 Elastic IP EC2 Setup Matters – How to Set Up Route 53

By default, an EC2 public IPv4 address is ephemeral. It is released when the instance stops and a different address is assigned when it starts again. That behaviour is fine for a short test, but it breaks production websites in several ways. DNS records must be edited after every change, and DNS caches around the world keep serving the old address until their TTL expires. An Elastic IP is a static public IPv4 address allocated to your AWS account that you can move between instances. Combined with Route 53, Amazon’s highly available DNS service, it gives you a stable endpoint and authoritative DNS that updates reliably, integrates with AWS health checks, and supports both simple A records and alias records for AWS resources.

Prerequisites for Route 53 Elastic IP EC2 – How to Set Up Route 53

  • An AWS account with permission to use EC2 and Route 53.
  • A running EC2 instance with a web server such as Nginx or Apache installed.
  • A registered domain name, either registered with Route 53 or with an external registrar.
  • The AWS CLI installed and configured if you want to follow the CLI steps, with a profile that can describe and associate addresses.
  • Basic familiarity with DNS concepts such as A records, TTL, and nameservers.

Before you begin, note your instance ID and its current region. Elastic IPs are regional, so the address must be allocated in the same region as the instance. Also open port 80 and, if you will use HTTPS, port 443 in the instance security group.

Step 1: Allocate an Elastic IP in the Console

  1. Open the EC2 console and select the correct region in the top navigation.
  2. In the left navigation, choose Network & Security, then Elastic IPs.
  3. Choose Allocate Elastic IP address, select Amazon’s pool of IPv4 addresses, and confirm allocation.
  4. Select the new address, choose Actions, then Associate Elastic IP address.
  5. Choose Instance, select your EC2 instance and its private IP, then associate.

After association, the instance’s public IP in the EC2 console changes immediately to the Elastic IP. Any previous public IP is released. Test connectivity by browsing to the new address or using curl from your terminal.

Step 2: Allocate and Associate with the AWS CLI

The same route 53 elastic ip ec2 workflow can be scripted with the AWS CLI, which is ideal for automation and repeatable deployments.

aws ec2 allocate-address --domain vpc --region us-east-1

The output contains the public IP and an AllocationId. Save both values. Associate the address with your instance next:

aws ec2 associate-address --instance-id i-0123456789abcdef0 --allocation-id eipalloc-0123456789abcdef0 --region us-east-1

Verify the association:

aws ec2 describe-addresses --region us-east-1
aws ec2 describe-instances --instance-ids i-0123456789abcdef0 --query "Reservations[].Instances[].PublicIpAddress" --output text

If you later need to release an unused address, first disassociate it, then release it. Remember that AWS charges a small hourly fee for an Elastic IP that is allocated but not associated with a running instance, so clean up unused addresses promptly.

Route 53 Elastic IP EC2 DNS propagation check illustration

Step 3: Create a Route 53 Hosted Zone

  1. Open the Route 53 console and choose Hosted zones, then Create hosted zone.
  2. Enter your domain name, for example example.com, choose Public hosted zone, and create it.
  3. Route 53 creates NS and SOA records automatically. Copy the four NS values.
  4. If your domain is registered elsewhere, sign in to that registrar and replace its nameservers with the four Route 53 values. If the domain is registered with Route 53, this is handled automatically.
  5. Wait for the nameserver change to take effect before testing public resolution thoroughly, although you can create records immediately.

For background and official terminology, see the Amazon Route 53 Developer Guide.

Step 4: Create an A Record Pointing to the Elastic IP

  1. In your hosted zone, choose Create record.
  2. For the root domain, leave the subdomain field blank. Enter www if you are creating the www record.
  3. Choose record type A, enter your Elastic IP as the value, set TTL to 300 seconds initially, and choose Simple routing.
  4. Create records for both the root domain and www so visitors can use either name. For www you may alternatively use a CNAME pointing to the root domain.
example.com    A    300    203.0.113.10
www.example.com A   300    203.0.113.10

Alias Records vs A Records

An A record points a hostname directly to an IPv4 address, which is exactly what an EC2 Elastic IP needs. An alias record is a Route 53 extension that points a hostname to an AWS resource such as an Application Load Balancer, CloudFront distribution, or S3 website endpoint, and it is resolved by Route 53 at query time. Alias records cannot point directly to an arbitrary EC2 public IP in the same way, so for a single EC2 website use an A record to the Elastic IP. Choose alias records when your target is a load balancer or another supported AWS endpoint, especially at the zone apex where a traditional CNAME is not allowed.

Step 5: TTL, Propagation, and Verification with dig

TTL, or time to live, controls how long resolvers cache a record. A low TTL such as 300 seconds helps changes propagate faster during setup, at the cost of slightly more queries. Once stable, many sites raise TTL to 3600 seconds or higher. Propagation is not a single event; it is resolvers expiring old cached answers at different times.

dig +short example.com
dig example.com NS
dig @ns-123.awsdns-12.com example.com A
nslookup example.com 8.8.8.8

Querying the authoritative nameserver directly confirms whether Route 53 is serving the correct record. Querying a public resolver shows what most visitors will see. Also test the website itself:

curl -I http://example.com
curl -I http://www.example.com

Reverse DNS Note

Reverse DNS maps an IP address back to a hostname via a PTR record. It matters mainly if your EC2 instance sends email directly, because receiving mail servers often check that reverse DNS matches the sending hostname and that forward DNS confirms it. For Elastic IPs, reverse DNS is not edited like a normal hosted zone record; you submit a request to AWS to set the PTR for the Elastic IP, and you must first create the matching forward A record. If you only serve a website, reverse DNS is usually not required, but setting it correctly helps if you later add transactional email from the server, though using a dedicated email service is generally recommended.

Troubleshooting Route 53 Elastic IP EC2 Issues

Website Still Shows the Old IP

Your local resolver or browser may be caching the old answer. Wait for the previous TTL to expire, flush your local DNS cache, and test with dig against 8.8.8.8 and 1.1.1.1. Confirm you edited the correct hosted zone and that the domain’s registrar points to its nameservers.

DNS Resolves but the Site Does Not Load

Check that the Elastic IP is associated with the right instance, the web server is running, and the security group allows inbound traffic on ports 80 and 443 from the internet. Test by browsing directly to the Elastic IP; if that fails, the problem is on the server, not in DNS.

NXDOMAIN or No NS Records Found

This usually means nameserver delegation is wrong. Compare the NS records at the registrar with the NS records in the Route 53 hosted zone character by character. A common mistake is having two hosted zones for the same domain and editing the one that is not delegated.

Charges for an Unattached Elastic IP

Review the Elastic IPs page, disassociate and release any address that is not needed. Set a reminder to clean up addresses when you terminate test instances.

Conclusion

A correct route 53 elastic ip ec2 setup gives your website a stable public address and reliable, authoritative DNS. Allocate the Elastic IP in the same region, associate it carefully, delegate your domain to the Route 53 hosted zone, create A records for the root and www names, and verify each stage with dig before assuming propagation is complete. With a sensible TTL and clean housekeeping of unused addresses, this foundation will support HTTPS, monitoring, and future moves to a load balancer without forcing visitors through another disruptive IP change.

You may also like

KbLinux

Typically replies within a day

Hello, Welcome to the site. Please click below button for chatting me through Telegram.