Infrastructure

DNS

Domain Name System - The internet's phonebook that translates human-readable domain names into IP addresses that computers use to communicate.

What is DNS?

DNS (Domain Name System) is a hierarchical, distributed naming system that translates human-readable domain names (like corsproxy.io) into machine-readable IP addresses (like 104.26.10.123). Think of it as the internet’s phonebook, making it possible to access websites using memorable names instead of numeric IP addresses.

How DNS Works

The DNS Resolution Process

When you type https://corsproxy.io in your browser:

  1. Browser Cache: Checks if IP is already cached locally
  2. OS Cache: Queries operating system’s DNS cache
  3. Recursive Resolver: Contacts ISP’s DNS server (or configured DNS like 8.8.8.8)
  4. Root Nameserver: Resolver asks root server for .io TLD nameserver
  5. TLD Nameserver: Root directs to .io top-level domain server
  6. Authoritative Nameserver: TLD directs to domain’s nameserver
  7. IP Address Returned: Authoritative server returns IP address
  8. Website Connection: Browser connects to IP address
// Browser automatically performs DNS lookup
fetch('https://corsproxy.io/api')
  // Before this request, DNS resolved corsproxy.io → 104.26.10.123
  .then(response => response.json());

DNS Hierarchy

.                           (Root)
├── .com                    (TLD - Top Level Domain)
│   ├── google.com          (Second-level domain)
│   └── facebook.com
├── .io                     (TLD)
│   ├── corsproxy.io       (Second-level domain)
│   └── github.io
└── .org                    (TLD)
    └── wikipedia.org

DNS Record Types

A Record (Address Record)

Maps domain to IPv4 address:

corsproxy.io.    A    104.26.10.123

AAAA Record

Maps domain to IPv6 address:

corsproxy.io.    AAAA    2606:4700::6818:a7b

CNAME Record (Canonical Name)

Creates alias pointing to another domain:

www.corsproxy.io.    CNAME    corsproxy.io.
api.corsproxy.io.    CNAME    corsproxy.io.

MX Record (Mail Exchange)

Specifies mail servers for domain:

corsproxy.io.    MX    10 mail.corsproxy.io.

TXT Record

Stores text information, used for verification and security:

corsproxy.io.    TXT    "v=spf1 include:_spf.google.com ~all"
corsproxy.io.    TXT    "google-site-verification=abc123..."

NS Record (Nameserver)

Delegates DNS zone to specific nameservers:

corsproxy.io.    NS    ns1.cloudflare.com.
corsproxy.io.    NS    ns2.cloudflare.com.

SRV Record (Service)

Defines location of services:

_service._proto.name.    TTL    class SRV priority weight port target.

DNS Caching and TTL

Time To Live (TTL)

corsproxy.io.    300    A    104.26.10.123
                 ^^^
                 TTL (seconds)

TTL determines how long DNS records can be cached:

Cache Levels

// DNS caching happens at multiple levels:

// 1. Browser cache (varies by browser)
// Chrome: ~60 seconds default

// 2. Operating system cache
// Windows: ipconfig /flushdns
// macOS: sudo dscacheutil -flushcache

// 3. Router cache

// 4. ISP resolver cache

// 5. CDN cache (for services like Cloudflare)

Flushing DNS Cache

# Windows
ipconfig /flushdns

# macOS
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

# Linux
sudo systemd-resolve --flush-caches

# Chrome browser
chrome://net-internals/#dns

DNS and Web Performance

DNS Lookup Time

// Measure DNS lookup time
performance.getEntriesByType('navigation')[0].domainLookupEnd -
performance.getEntriesByType('navigation')[0].domainLookupStart;
// Typical: 20-120ms

Optimization Strategies

1. DNS Prefetching

<!-- Tell browser to resolve DNS ahead of time -->
<link rel="dns-prefetch" href="//api.example.com">
<link rel="dns-prefetch" href="//cdn.example.com">

2. DNS Preconnect

<!-- Resolve DNS + establish TCP connection + TLS handshake -->
<link rel="preconnect" href="https://api.example.com">

3. Use Fast DNS Providers

# Change DNS resolver (Linux)
echo "nameserver 1.1.1.1" | sudo tee /etc/resolv.conf

4. Minimize DNS Lookups

// Multiple domains = multiple DNS lookups
await fetch('https://api1.example.com/data');
await fetch('https://api2.example.com/data');
await fetch('https://api3.example.com/data');

// Single domain = one DNS lookup
await fetch('https://api.example.com/service1/data');
await fetch('https://api.example.com/service2/data');
await fetch('https://api.example.com/service3/data');

DNS Security

DNS Spoofing/Cache Poisoning

Attackers inject fake DNS records to redirect traffic:

You want:  corsproxy.io → 104.26.10.123 (real)
Attacker:  corsproxy.io → 192.0.2.1 (fake)

Protections:

DNSSEC (DNS Security Extensions)

Cryptographically signs DNS records:

# Check DNSSEC validation
dig +dnssec corsproxy.io

# Look for RRSIG records
corsproxy.io.  300  IN  RRSIG  A 13 2 300 20240115... (signature)

DNS over HTTPS (DoH)

Encrypts DNS queries using HTTPS:

// Modern browsers support DoH
// Configure in browser settings or programmatically

// Example: Using DoH with fetch API
const dohLookup = async (domain: string) => {
  const response = await fetch(
    `https://cloudflare-dns.com/dns-query?name=${domain}&type=A`,
    {
      headers: {
        'Accept': 'application/dns-json'
      }
    }
  );
  return response.json();
};

const result = await dohLookup('corsproxy.io');
console.log('IP addresses:', result.Answer.map(a => a.data));

DNS over TLS (DoT)

Similar to DoH but uses dedicated port (853):

# Configure systemd-resolved for DoT
echo "DNS=1.1.1.1" | sudo tee -a /etc/systemd/resolved.conf
echo "DNSOverTLS=yes" | sudo tee -a /etc/systemd/resolved.conf
sudo systemctl restart systemd-resolved

DNS in Web Development

Programmatic DNS Lookups

// Node.js DNS module
import dns from 'dns/promises';

// A record lookup
const addresses = await dns.resolve4('corsproxy.io');
console.log('IPv4:', addresses); // ['104.26.10.123', ...]

// AAAA record lookup
const ipv6 = await dns.resolve6('corsproxy.io');
console.log('IPv6:', ipv6);

// MX records
const mxRecords = await dns.resolveMx('corsproxy.io');
console.log('Mail servers:', mxRecords);

// TXT records
const txtRecords = await dns.resolveTxt('corsproxy.io');
console.log('TXT:', txtRecords);

// Reverse DNS lookup
const hostnames = await dns.reverse('104.26.10.123');
console.log('Hostname:', hostnames);

DNS and CORS

DNS doesn’t directly affect CORS, but subdomains matter:

// Different origins due to subdomain differences
const origin1 = 'https://corsproxy.io';           // Origin A
const origin2 = 'https://www.corsproxy.io';       // Origin B (different!)
const origin3 = 'https://api.corsproxy.io';       // Origin C (different!)

// CORS must explicitly allow each subdomain
// Or use wildcard (not recommended for credentials)
Access-Control-Allow-Origin: *

CorsProxy handles this complexity:

// CorsProxy manages CORS for any domain
const data = await fetch(
  'https://corsproxy.io/?url=https://api.different-origin.com/data',
  {
    headers: { 'x-cors-api-key': 'your-key' }
  }
).then(r => r.json());

DNS Load Balancing

Geographic DNS

# Different IPs for different regions
corsproxy.io.    A    104.26.10.123    (US)
corsproxy.io.    A    172.67.150.45    (EU)
corsproxy.io.    A    104.26.11.234    (Asia)

Round-Robin DNS

# Multiple IPs for load distribution
api.example.com.    A    192.0.2.1
api.example.com.    A    192.0.2.2
api.example.com.    A    192.0.2.3

Each DNS query returns IPs in different order, distributing load.

CorsProxy Global Network

CorsProxy uses Cloudflare’s Anycast DNS:

Common DNS Issues

DNS Propagation Delay

# Check DNS propagation globally
# Use: whatsmydns.net or dnschecker.org

# Different results during propagation:
# US East:   corsproxy.io → 104.26.10.123 (new)
# EU West:   corsproxy.io → 104.26.9.222  (old)
# Asia:      corsproxy.io → NXDOMAIN      (not propagated)

Typical propagation time: 24-48 hours (but often faster)

NXDOMAIN (Non-Existent Domain)

fetch('https://nonexistent.corsproxy.io/api')
  .catch(error => {
    // Error: getaddrinfo ENOTFOUND nonexistent.corsproxy.io
  });

Causes:

DNS Timeout

// DNS query timeout (usually 30 seconds)
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 30000);

fetch('https://slow-dns.example.com', { signal: controller.signal })
  .catch(error => {
    // Error: The operation was aborted
  });

DNS Tools and Debugging

Command-Line Tools

# nslookup - Simple DNS lookup
nslookup corsproxy.io

# dig - Detailed DNS information
dig corsproxy.io
dig corsproxy.io +trace    # Show full resolution path
dig corsproxy.io ANY       # All record types

# host - Reverse DNS lookup
host 104.26.10.123

# whois - Domain registration info
whois corsproxy.io

Browser DevTools

// Chrome DevTools → Network → Name column shows DNS timing
// Right-click headers → choose columns → add "DNS Lookup Time"

// Or use Navigation Timing API
const nav = performance.getEntriesByType('navigation')[0];
console.log('DNS Lookup:', nav.domainLookupEnd - nav.domainLookupStart, 'ms');

DNS Providers

Managed DNS Benefits

  1. High Availability: Multiple redundant nameservers
  2. DDoS Protection: Absorb volumetric attacks
  3. Fast Propagation: Optimized global distribution
  4. DNSSEC Support: Enhanced security
  5. Analytics: Query statistics and insights

DNS and Privacy

DNS Leaks

# Check for DNS leaks
# Visit: dnsleaktest.com

# Your DNS queries reveal:
- Websites you visit
- When you visit them
- Your approximate location

Solutions:

DNS Tracking

DNS queries can be logged by:

Cloudflare’s 1.1.1.1 promises:

Best Practices

  1. Use reliable DNS providers: Cloudflare, Google, or managed services
  2. Enable DNSSEC: Protect against spoofing
  3. Implement DoH/DoT: Encrypt DNS queries
  4. Set appropriate TTLs: Balance performance vs. flexibility
  5. Monitor DNS health: Track query times and failures
  6. Use DNS prefetching: Improve page load times
  7. Implement redundancy: Multiple nameservers
  8. Regular audits: Review and clean up DNS records

Learn More

Create a free Account to fix CORS Errors in Production

Say goodbye to CORS errors and get back to building great web applications. It's free!

CORSPROXY Dashboard

Related Terms

More in Infrastructure

Related guides

Back to Glossary