How to access a name based website without a DNS record

The /etc/hosts file on a Linux system is a critical configuration file that maps hostnames to IP addresses. This file allows a user to manually associate specific IP addresses with domain names, effectively bypassing the DNS (Domain Name System) lookup process for these entries. The file typically contains lines of text where each line represents an IP address followed by one or more hostnames. For example, it might map "127.0.0.1" to "localhost," ensuring that the local machine recognizes this hostname without needing to consult an external DNS server. System administrators often use /etc/hosts to define local network resources, test new server setups, or override DNS settings temporarily. This file plays a vital role in network configuration and troubleshooting on Linux systems.

If you want to access a name-based website that you created e.g. in ISPConfig before the DNS records are set up, edit the hosts file on your workstation computer and add a line like this:

192.168.0.100        www.mydomain.com mydomain.com

Edit hosts file on macOS X

To edit the hosts file on a computer running macOS X, use this command:

sudo nano /etc/hosts

Replace the IP address with the IP of your server and www.mydomain.com with the domain name of the website.

Windows 10 and 11 hosts File location

The hosts file on Linux and MAC systems is /etc/hosts, on Windows systems, the hosts file is:

C:\Windows\system32\drivers\etc\hosts

The above trick also works if you want to run a website in your internal network (intranet) without having a DNS server available for local DNS resolving.

Leave a Comment