Modifying The Windows Host File

1 minute read

Description:

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.

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:

192.168.1.10(tab)Server01

  1. This is optional – Go to http://winhelp2002.mvps.org/hosts.txt and copy and paste this into the file to block advertisements while you are in there!

If It Doesn’t Let You Save:

  1. Run – cmd – sfc /scannow

  2. Rename the host file and recreate it from another workstation. Make sure to take off the extension so that it’s just a plain “file”.


Description:

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. Start – cmd – Right click and Run As Administrator.

  2. Type:

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.