microsoft toolkit download

How To Modify/Edit Windows Hosts File?

The hosts file is used to specify local DNS records with hostname and IP relation. Normally DNS work with DNS servers in order to resolve hostnames into IP addresses but the hosts file can be used to specify the IP address and related hostname records for the local system. The hosts file can be used to create temporary or permanent simple DNS records to solve hostname into the IP address without the need to modify global or enterprisewide DNS server records. In this tutorial, we examine how to edit or modify the Windows hosts file in order to add, update or remove a DNS record.

Hosts File Location

The hosts file is located under the system directory Windows . It can be accessed via “c:\Windows\System32\Drivers\etc\” path. The hosts file is a simple text file without any extension. In the following screenshot, we can see that the hosts file is very little which is 1KB and the type of the hosts file is specified as “File” which means file with no extension or type.

Hosts File Location

If the Windows installation is other than “C:\” the required partitions should be specified or alternatively the %system can be used to specify the Windows directory.

%system%\System32\Drivers\etc\

The defualt content of the hosts file is like below.

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#       127.0.0.1       localhost
#       ::1             localhost

Open Hosts File with Notepad

The Notepad can be used to open and edit the hosts file. The notepad text editor is provided by all Windows operating systems by default. But as editing the hosts file requires Administrative or Administrator privileges and so the Notepad should be opened as Administrator to provide the required privileges to edit hosts file.

  • Click to the “Start Menu”
  • Type “notepad” which lists the notepad
  • Right click to the listed Notepad applications and click to the Run as administrator .
Open Notepad as Administrator

There click to the “File” menu and select “Open…” in order to specify the hosts file location.

In the open dialog use “C:\Windows\System32\Drivers\etc\hosts” in order to open the hosts file.

Open hosts File with Notepad

The opened hosts file looks like below.

Add New DNS Record

Adding new DNS record to the hosts file is very easy. A DNS record consist of the IP address and domain name like below.

192.168.1.1   windowstect.com

Leave a Comment