12. Domains and DNS: GoDaddy, Elastic IP, A/CNAME and Subdomains
12.2 Preparing the Server: Elastic IP and Security Group
- A working website on EC2, tested with
curl -I http://localhostandhttp://<PUBLIC_IP>(Chapter 8 and 8). -
An Elastic IP, so the address never changes after stop/start. Quick steps:
- EC2 console → Network & Security → Elastic IPs → Allocate Elastic IP address → Allocate.
- Select it → Actions → Associate Elastic IP address → choose your instance → Associate.
- Note the address, e.g.
203.0.113.10. SSH now uses this IP too.
(Charges, the default limit of 5 per region, moving an EIP to a replacement server and releasing it safely are covered in detail in Chapter 12.) 3. Security group: inbound HTTP 80 and HTTPS 443 from
0.0.0.0/0(and::/0for IPv6).
Never point DNS to the auto-assigned public IP
It changes on every stop/start. Your domain would then point to an IP that may soon belong to someone else's instance. Always use an Elastic IP (or a load balancer).
Elastic IP charges
Public IPv4 addresses, including Elastic IPs, are charged by AWS. Release Elastic IPs you no longer need (Disassociate, then Release). Check the AWS pricing page for current details – the UI and pricing may change.
Ravindra Bagale's Tip
You pointed the domain at the auto-assigned public IP and then stopped and started the instance – now the domain may point at someone else's server! Many students have made this mistake. First the Elastic IP, then DNS – never break this order.
Ravindra Bagale's Tip – मराठी
Domain auto-assigned public IP ला point केला आणि instance stop-start केला – आता domain दुसऱ्याच्या server ला point करू शकतो! बऱ्याच students नी ही चूक केली आहे. आधी Elastic IP, मग DNS – हा क्रम कधी मोडू नका.
Ravindra Bagale's Tip – हिंदी
Domain को auto-assigned public IP पर point किया और instance stop-start कर दिया – अब domain किसी और के server पर point कर सकता है! बहुत से students ने यह गलती की है. पहले Elastic IP, फिर DNS – यह क्रम कभी मत तोड़ो.
Practice task
Allocate an Elastic IP, associate it with your web server, and SSH to the server using the new address.