DNS Explained – How Domains Actually Work (And How to Configure Them)

πŸ“Œ Quick Summary
    🧱 Table of Contents

    Every time you visit a website, something critical happens behind the scenes:

    πŸ‘‰ A domain name is translated into an IP address.

    This process is called DNS (Domain Name System) β€” and understanding it is essential for:

    • Hosting servers
    • Managing domains
    • Running self-hosted apps

    πŸ”Ή What is DNS?

    DNS is like the phonebook of the internet.

    Instead of remembering:

    142.250.74.78

    You use:

    google.com

    DNS resolves the domain β†’ IP.

    πŸ”Ή How DNS Works (Step-by-Step)

    1. You type a domain (e.g. example.com)
    2. Request goes to a DNS resolver (ISP or public DNS)
    3. Resolver queries:
      • Root servers
      • TLD servers (.com)
      • Authoritative server
    4. IP is returned β†’ browser connects

    πŸ”Ή Common DNS Record Types

    A Record

    Points domain β†’ IPv4

    example.com β†’ 192.168.1.1

    AAAA Record

    Points domain β†’ IPv6

    example.com β†’ 2001:db8::1

    CNAME Record

    Alias for another domain

    www.example.com β†’ example.com

    MX Record

    Mail servers

    example.com β†’ mail.example.com

    TXT Record

    Used for:

    • Verification
    • SPF, DKIM (email security)

    πŸ”Ή Real Example (Cloudflare Setup)

    Using Cloudflare DNS:

    TypeNameValue
    Aexample.comyour-server-ip
    CNAMEwwwexample.com
    Aappyour-server-ip

    πŸ”Ή DNS Propagation

    After changing DNS:

    • It can take seconds β†’ 24 hours
    • Depends on TTL (Time To Live)

    πŸ”Ή Check DNS Records

    dig example.com

    or

    nslookup example.com

    πŸ”Ή Pro Tips (Advanced)

    • Use low TTL while testing (300 seconds)
    • Use separate subdomains for services:
      • app.domain.com
      • api.domain.com
    • Never expose internal services directly

    πŸ”Ή Common Mistakes

    ❌ Wrong IP address
    ❌ Missing CNAME for www
    ❌ Mixing proxy + direct DNS incorrectly

    πŸ”Ή Conclusion

    Understanding DNS gives you:

    • Full control over your infrastructure
    • Cleaner architecture
    • Better security

    πŸ‘‰ It’s the foundation of everything in networking.

    Leave a comment

    Your email address will not be published. Required fields are marked *