Local Name Resolution

This refers to the process where a local machine resolves domain names using its own configuration, overriding external DNS servers.

Hosts File

A local file that maps IP addresses to hostnames, providing a way to override DNS server resolutions. This is useful for testing or custom configurations.

How to Access

  • Linux: /etc/hosts

  • Windows: C:\Windows\System32\drivers\etc\hosts

  • Mac: /etc/hosts

The hosts file contains a list of IP addresses and associated hostnames and is used for local name resolution before querying external DNS servers.

# This is a sample hosts file used for local name resolution.
# IP Address    Hostname                Alias (Optional)

127.0.0.1       localhost
192.168.1.100   testserver.local        testserver
203.0.113.5     mywebsite.com           www.mywebsite.com
10.0.0.10       intranet.local

# Block a site by pointing it to localhost
127.0.0.1       ads.example.com

Why the Precedence?

A local host query takes precedence over external DNS servers because the system checks the hosts file first during the name resolution process. The hosts file is a local, static list of IP addresses and hostnames. Since it is on the local machine, it's faster to access and trusted for overriding DNS lookups. This allows custom or internal configurations to resolve domain names before reaching out to external DNS servers, ensuring priority for predefined local mappings.

Last updated