Understanding DNS Basics and Queries

Sep 18, 2024

TryHackMe DNS Room Lecture Notes

Introduction

  • Presenter: John
  • Topic: Understanding DNS (Domain Name System)
  • Objective: Learn how DNS works to facilitate internet access.

Task 1: What is DNS?

  • DNS Definition: Domain Name System.
  • Purpose: Allows communication with devices on the internet without using IP addresses.
  • IP Address Format: Four octets (e.g., 192.168.1.1).
  • DNS Function: Maps domain names (e.g., tryhackme.com) to IP addresses.

Task 2: Domain Hierarchy

Top Level Domains (TLD)

  • TLD Definition: Rightmost part of a domain name (e.g., .com, .org).
  • Types of TLDs:
    • gTLD: Generic (e.g., .com, .org, .edu)
    • ccTLD: Country Code (e.g., .ca, .co.uk)
  • New TLDs: Constantly emerging, e.g., .online, .club.

Second Level Domain

  • Example: In "tryhackme.com", "tryhackme" is the second level domain.
  • Restrictions:
    • 63 character limit
    • Characters allowed: A-Z, 0-9, hyphens (no starting/ending hyphens).

Subdomains

  • Example: admin.tryhackme.com ("admin" is the subdomain).
  • Restrictions:
    • Same as second-level domain
    • Maximum length: 63 characters
    • Unlimited creation

Task 3: DNS Record Types

Common DNS Records

  • A Record: Resolves to IPv4 address.
  • Pointer Records: For reverse lookups.
  • Quad A Record: Resolves to IPv6 address.
  • CNAME Record: Canonical name; maps domain to another domain.
  • MX Record: Specifies mail exchange servers for domain.
  • TXT Record: Stores text-based data (e.g., spam prevention, domain verification).

Task 4: Making a DNS Request

DNS Request Process

  1. Local Cache: Checks recent lookups.
  2. Recursive DNS Server: Usually ISP-provided; checks own cache.
  3. Root DNS Servers: Redirect based on TLD.
  4. TLD Servers: Directs to authoritative server.
  5. Authoritative DNS Server: Provides final DNS record.
  • TTL (Time to Live): Duration to cache response.

Task 5: Practical DNS Queries

  • Using Website Queries: Practice DNS query commands.
  • Example Queries:
    • CNAME for shop.website.thm
    • TXT record value for website.thm
    • MX record priority value
    • A record IP address for www.website.thm

Conclusion

  • Resources: TryHackMe Discord and Subreddit for questions.
  • Encouragement: Continue exploring DNS and happy hacking!