Modifying The Windows Host File

1 minute read


Sometimes, you may want to check the Windows Host file for bogus redirects by viruses or if you just want the computer to know to resolve a particular IP to a hostname, you will want to modify this file. Editing the Windows host file is a common task for administrators for post malware cleanup or to set their own values. The Windows host file is a basic “go-to” file that Windows uses for DNS before reaching out to the DNS Server configured in the NIC properties.

To Resolve:

  1. Run => C:\Windows\System32\Drivers\Etc => open that up. Navigate to the host file => double click => open with => Notepad. Alternatively, you may have to Search => notepad => right-click => “run as administrator”. Once opened, navigate to that directory and open “hosts”.

  2. Once inside, make sure the bottom doesn’t have any phony IP addresses to host names. While your in there, add the server to your network by going to the last line => enter the IP address of the server (which should be static) => Tab => the Servers Name. Example: Server01

  3. This is optional => Go to Winhelp and copy and paste this into the file to block advertisements while you are in there!

  4. run => cmd =>

    cd \
    takeown /f c:\windows\system32\drivers\etc\hosts
    icacls c:\windows\system32\drivers\etc\hosts /grant:r :f
    attrib -R c:\windows\system32\drivers\etc\hosts
    notepad c:\windows\system32\drivers\etc\hosts
    # Enter whatever you want and click "save" to save your changes.