Ravindra BagaleCourses & study guides मराठी Track your progress

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.

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!

 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

  1. 9.1What is a domain name?
  2. 9.2How DNS resolution works
  3. 9.3DNS record types you must know
  4. 9.4Before you point a domain: prepare the server
  5. 9.5Buying a domain on GoDaddy
  6. 9.6Pointing a GoDaddy domain to EC2 (GoDaddy DNS)
  7. 9.7Alternative: GoDaddy registrar + Route 53 DNS
  8. 9.8Configure the web server for the domain
  9. 9.9Verify DNS: dig, nslookup and friends
  10. 9.10Subdomains
  11. 9.11HTTPS for your domain and subdomains
  12. 9.12Troubleshooting domains

Review and practice

  1. ★Common Mistakes I See Students Make
  2. ★Interview Questions
  3. ★Practice Questions and Lab Exercises

Practice Tasks

About this scenario

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.

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. 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.

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. 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.

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. 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?

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. 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.

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. 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.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. 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.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. 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.

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. 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.

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. 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/.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.