Chapter 9: Domain Names, DNS and Subdomains
Hello friends! So far we opened our website with an IP address. But how will the customers of Mauli Dairy, Pune (a fictional business, only for learning) remember that number? In this chapter we give the server a real name – domain, www and subdomains – and understand what happens behind the scenes when someone types the name. We take GoDaddy as the example, but the steps are almost the same at other registrars. Keep both the browser and the terminal open.
नमस्कार मित्रांनो! आतापर्यंत आपण वेबसाइट IP ॲड्रेसने उघडली. पण Mauli Dairy, Pune (फिक्शनल बिझनेस, फक्त शिकण्यासाठी) चे कस्टमर्स हा नंबर कसा लक्षात ठेवणार? या चॅप्टरमध्ये आपण सर्व्हरला खरं नाव देऊ – डोमेन, www आणि सबडोमेन्स – आणि नाव टाइप केल्यावर मागे काय होतं ते समजू. GoDaddy उदाहरण म्हणून घेऊ, पण बाकी रजिस्ट्रार्सवर पण स्टेप्स जवळजवळ सारख्याच आहेत. ब्राउझर आणि टर्मिनल दोन्ही उघडे ठेवा.
नमस्ते दोस्तों! अब तक हमने वेबसाइट IP एड्रेस से खोली. पर Mauli Dairy, Pune (फ़िक्शनल बिज़नेस, सिर्फ़ सीखने के लिए) के कस्टमर्स ये नंबर कैसे याद रखेंगे? इस चैप्टर में हम सर्वर को असली नाम देंगे – डोमेन, www और सबडोमेन्स – और समझेंगे कि नाम टाइप करने पर पीछे क्या होता है. GoDaddy को उदाहरण के तौर पर लेंगे, पर बाकी रजिस्ट्रार्स पर भी स्टेप्स लगभग एक जैसे हैं. ब्राउज़र और टर्मिनल दोनों खुले रखो.
What you will learn in this chapter
- Parts of a domain name
- How DNS resolution works
- Record types and TTL
- Elastic IP before DNS
- GoDaddy DNS and Route 53
- server_name for your domain
- dig, nslookup and caches
- Subdomains and HTTPS
Friends, so far we have opened our websites with http://13.233.10.25. It works, but nobody will remember that number, and you can't put it on a visiting card. In this chapter we give our server a real name like example.com, add www, create subdomains like blog.example.com and api.example.com, and understand what happens behind the scenes when someone types that name. We'll use GoDaddy as the registrar example because many of you already have an account there, but the steps are almost the same on Namecheap, Hostinger, BigRock or Route 53. Come on, let's give our server a name – and Mauli Dairy's website too!
मित्रांनो, आतापर्यंत आपण आपल्या वेबसाइट्स http://13.233.10.25 ने उघडल्या. ते चालतं, पण हा नंबर कोणाच्याच लक्षात राहणार नाही, आणि तो व्हिजिटिंग कार्डवर टाकता येत नाही. या चॅप्टरमध्ये आपण सर्व्हरला example.com सारखं खरं नाव देऊ, www जोडू, blog.example.com आणि api.example.com सारखे सबडोमेन्स बनवू, आणि कोणी ते नाव टाइप केल्यावर मागे काय होतं ते समजू. रजिस्ट्रारचं उदाहरण म्हणून GoDaddy वापरू कारण तुमच्यापैकी खूप जणांचं तिथे आधीच अकाउंट आहे, पण Namecheap, Hostinger, BigRock किंवा Route 53 वर स्टेप्स जवळजवळ सारख्याच आहेत. चला, आपल्या सर्व्हरला नाव देऊया – Mauli Dairy च्या वेबसाइटला पण!
दोस्तों, अब तक हमने अपनी वेबसाइट्स http://13.233.10.25 से खोलीं. ये चलता है, पर ये नंबर किसी को याद नहीं रहेगा, और इसे विज़िटिंग कार्ड पर नहीं डाल सकते. इस चैप्टर में हम सर्वर को example.com जैसा असली नाम देंगे, www जोड़ेंगे, blog.example.com और api.example.com जैसे सबडोमेन्स बनाएँगे, और समझेंगे कि कोई वो नाम टाइप करे तो पीछे क्या होता है. रजिस्ट्रार के उदाहरण के लिए GoDaddy लेंगे क्योंकि आप में से कई लोगों का वहाँ पहले से अकाउंट है, पर Namecheap, Hostinger, BigRock या Route 53 पर स्टेप्स लगभग एक जैसे हैं. चलो, अपने सर्वर को नाम देते हैं – Mauli Dairy की वेबसाइट को भी!
You type example.com
|
v
+-------------+ 1. "IP of example.com?" +----------------+ 2. root servers
| Browser / | ------------------------> | DNS resolver | 3. .com TLD servers
| OS cache | <------------------------ | (recursive) | 4. authoritative NS
+-------------+ 6. "13.233.10.25" +----------------+ (GoDaddy / Route 53)
| ^
| 7. HTTP GET Host: example.com | 5. A example.com = 13.233.10.25 (+ TTL)
v |
+-------------------------------+ +------------------+
| EC2 (Elastic IP 13.233.10.25) | | Authoritative NS |
| Nginx/Apache: server_name | +------------------+
+-------------------------------+
Concepts in this chapter
- 9.1What is a domain name?
- 9.2How DNS resolution works
- 9.3DNS record types you must know
- 9.4Before you point a domain: prepare the server
- 9.5Buying a domain on GoDaddy
- 9.6Pointing a GoDaddy domain to EC2 (GoDaddy DNS)
- 9.7Alternative: GoDaddy registrar + Route 53 DNS
- 9.8Configure the web server for the domain
- 9.9Verify DNS: dig, nslookup and friends
- 9.10Subdomains
- 9.11HTTPS for your domain and subdomains
- 9.12Troubleshooting domains
Review and practice
Practice Tasks
Lisboa Tiles is a ceramic tiles business in Lisbon. João Silva looks after its IT and cloud work. They count money in EUR and run their AWS resources in the eu-west-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.
0 / 10
Easy List hosted zones
Why: You need the zone ID to change records.
What to do: List all hosted zones in the account.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Create a hosted zone
Why: A hosted zone holds all DNS records for your domain.
What to do: Create a public hosted zone for lisboatiles.pt, with caller reference lisboatiles-2026-01.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium List records in a zone
Why: Check what A, CNAME and MX records exist before you change them.
What to do: List the record sets in hosted zone Z0123456789ABCDEFGHIJ.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Find the Amazon DNS address
Why: The VPC DNS resolver sits at base+2 of the VPC range.
What to do: The VPC is 10.57.0.0/16. What is the Amazon-provided DNS server address?
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Medium Attach the Elastic IP to the server
Why: Associating gives the server the fixed public IP that your domain points to.
What to do: Associate allocation eipalloc-012b3b140dcdd44 with instance i-0cd041b3b21011a2b.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Look up a DNS record
Why: dig shows what IP a name points to, so you can check DNS changes.
What to do: Look up the A record of www.lisboatiles.pt.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Medium Test the nginx config
Why: A test catches typos before a restart takes your site down.
What to do: Check the nginx configuration files for errors.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.
Hard Create or update a DNS record
Why: UPSERT creates the record or updates it if it already exists.
What to do: Apply the record changes in change.json to hosted zone Z0123456789ABCDEFGHIJ.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Hard Create a health check
Why: Failover routing needs a health check to know when the main site is down.
What to do: Create a health check with caller reference hc-lisboatiles-1 using the config in hc.json.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Hard Enable an nginx site on Ubuntu
Why: On Ubuntu, a site is enabled by a symbolic link from sites-available to sites-enabled.
What to do: Create a symbolic link to /etc/nginx/sites-available/lisboatiles inside /etc/nginx/sites-enabled/.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Use sudo if the job changes system files or users. Click Check answer.