How to change host file
How to change host file
How to reset the Hosts file back to the default
Summary
This article helps you reset the Hosts file back to the default.
What’s the Hosts file
The Hosts file is used by the operating system to map human-friendly hostnames to numerical Internet Protocol (IP) addresses which identify and locate a host in an IP network. The hosts file is one of several system resources that address network nodes in a computer network and is a common part of an operating system’s IP implementation.
The Hosts file contains lines of text consisting of an IP address in the first text field followed by one or more host names. Each field is separated by white space (Tabs are often preferred for historical reasons, but spaces are also used). Comment lines may be included, and they are indicated by a hash character (#) in the first position of such lines. Entirely blank lines in the file are ignored.
If the Hosts file is changed from default, resetting it can help resolve some connectivity issues.
Resolution
To reset the Hosts file back to the default, follow these steps according to your operating system:
To reset the Hosts file back to the default, follow these steps:
Open Notepad. To do this, search for “Notepad” using Cortana, and then tap or click the Notepad icon.
Copy the following text, and then paste the text into the file: # Copyright (c) 1993-2006 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 handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost
On the File menu, select Save as, type «hosts» in the File name box (as displayed in the following image), and then save the file to the desktop.
Search for %WinDir%\System32\Drivers\Etc using Cortana, and then select the File folder icon.
Tap and hold or right-click the Hosts file, select Rename, and then rename the file as «Hosts.old».
Copy or move the Hosts file that you created in step 3 from the desktop to the %WinDir%\System32\Drivers\Etc folder. If you are prompted to enter an administrator password, select Continue.
To reset the Hosts file back to the default, follow these steps:
Open Notepad. To do this, swipe in from the right edge of the screen, tap Search, type Notepad, and then tap the Notepad icon. Or, if you are using a mouse, point to the upper-right corner of the screen, move the mouse pointer down, click Search, type Notepad, and then click Notepad.
Copy the following text, and then paste the text into the file: # Copyright (c) 1993-2006 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 handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost
On the File menu, select Save as, type «hosts» in the File name box (as displayed in the following image), and then save the file to the desktop.
Open the %WinDir%\System32\Drivers\Etc folder. To do this, follow these steps:
Swipe in from the right edge of the screen, tap Search, type run, and then tap the Run icon. Or, if you are using a mouse, point to the upper-right corner of the screen, move the mouse pointer down, select Search, type run, and then select the Run icon.
Type %WinDir%\System32\Drivers\Etc in the Open box, and then select OK.
Select the Hosts file, select Rename, and then rename the file as «Hosts.old».
Copy or move the Hosts file that you created in step 3 to the %WinDir%\System32\Drivers\Etc folder. If you are prompted to enter an administrator password, tap or click Continue.
To reset the Hosts file back to the default yourself, follow these steps:
Click Start, click Run, type Notepad, and then click OK.
Copy the following text to the file:
For Windows 7 # Copyright (c) 1993-2006 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 handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost For Windows Vista or for Windows Server 2008 # Copyright (c) 1993-2006 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 127.0.0.1 localhost ::1 localhost For Windows XP or for Windows Server 2003 # Copyright (c) 1993-1999 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 127.0.0.1 localhost
On the File menu, select Save as, type «hosts» in the File name box, and then save the file to the desktop.
Select Start > Run, type %WinDir%\System32\Drivers\Etc, and then select OK.
Select the Hosts file, and rename it «Hosts.old.»
Copy or move the Hosts file that you created in step 3 to the %WinDir%\System32\Drivers\Etc folder. If you are prompted to enter an administrator password, select Continue.
Support for Windows XP has ended
Microsoft ended support for Windows XP on April 8, 2014. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.
Support for Windows Server 2003 ended on July 14, 2015
Microsoft ended support for Windows Server 2003 on July 14, 2015. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.
How to reset the Hosts file back to the default
Summary
This article helps you reset the Hosts file back to the default.
What’s the Hosts file
The Hosts file is used by the operating system to map human-friendly hostnames to numerical Internet Protocol (IP) addresses which identify and locate a host in an IP network. The hosts file is one of several system resources that address network nodes in a computer network and is a common part of an operating system’s IP implementation.
The Hosts file contains lines of text consisting of an IP address in the first text field followed by one or more host names. Each field is separated by white space (Tabs are often preferred for historical reasons, but spaces are also used). Comment lines may be included, and they are indicated by a hash character (#) in the first position of such lines. Entirely blank lines in the file are ignored.
If the Hosts file is changed from default, resetting it can help resolve some connectivity issues.
Resolution
To reset the Hosts file back to the default, follow these steps according to your operating system:
To reset the Hosts file back to the default, follow these steps:
Open Notepad. To do this, search for “Notepad” using Cortana, and then tap or click the Notepad icon.
Copy the following text, and then paste the text into the file: # Copyright (c) 1993-2006 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 handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost
On the File menu, select Save as, type «hosts» in the File name box (as displayed in the following image), and then save the file to the desktop.
Search for %WinDir%\System32\Drivers\Etc using Cortana, and then select the File folder icon.
Tap and hold or right-click the Hosts file, select Rename, and then rename the file as «Hosts.old».
Copy or move the Hosts file that you created in step 3 from the desktop to the %WinDir%\System32\Drivers\Etc folder. If you are prompted to enter an administrator password, select Continue.
To reset the Hosts file back to the default, follow these steps:
Open Notepad. To do this, swipe in from the right edge of the screen, tap Search, type Notepad, and then tap the Notepad icon. Or, if you are using a mouse, point to the upper-right corner of the screen, move the mouse pointer down, click Search, type Notepad, and then click Notepad.
Copy the following text, and then paste the text into the file: # Copyright (c) 1993-2006 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 handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost
On the File menu, select Save as, type «hosts» in the File name box (as displayed in the following image), and then save the file to the desktop.
Open the %WinDir%\System32\Drivers\Etc folder. To do this, follow these steps:
Swipe in from the right edge of the screen, tap Search, type run, and then tap the Run icon. Or, if you are using a mouse, point to the upper-right corner of the screen, move the mouse pointer down, select Search, type run, and then select the Run icon.
Type %WinDir%\System32\Drivers\Etc in the Open box, and then select OK.
Select the Hosts file, select Rename, and then rename the file as «Hosts.old».
Copy or move the Hosts file that you created in step 3 to the %WinDir%\System32\Drivers\Etc folder. If you are prompted to enter an administrator password, tap or click Continue.
To reset the Hosts file back to the default yourself, follow these steps:
Click Start, click Run, type Notepad, and then click OK.
Copy the following text to the file:
For Windows 7 # Copyright (c) 1993-2006 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 handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost For Windows Vista or for Windows Server 2008 # Copyright (c) 1993-2006 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 127.0.0.1 localhost ::1 localhost For Windows XP or for Windows Server 2003 # Copyright (c) 1993-1999 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 127.0.0.1 localhost
On the File menu, select Save as, type «hosts» in the File name box, and then save the file to the desktop.
Select Start > Run, type %WinDir%\System32\Drivers\Etc, and then select OK.
Select the Hosts file, and rename it «Hosts.old.»
Copy or move the Hosts file that you created in step 3 to the %WinDir%\System32\Drivers\Etc folder. If you are prompted to enter an administrator password, select Continue.
Support for Windows XP has ended
Microsoft ended support for Windows XP on April 8, 2014. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.
Support for Windows Server 2003 ended on July 14, 2015
Microsoft ended support for Windows Server 2003 on July 14, 2015. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.
How to Edit the HOSTS File in Windows
Customize your network settings in Windows 10, 8, or 7
What to Know
Here’s how to edit the Windows HOSTS file, which is necessary to make custom domain redirects, block websites, or remove malicious entries set by malware. Instructions apply to Windows 10, 8, 7, and XP.
How to Edit the Windows HOSTS File
In Windows 10, 8, and 7, you can’t save edits to the HOSTS file unless you open it directly from Notepad or another text editor. To do so:
Open Notepad or another text editor like Notepad++.
In the text editor, select File > Open and open the HOST file location at C:\Windows\System32\drivers\etc\.
Select Text Documents (*txt) in the bottom-right of the Open window and change it to All Files.
When files appear in the folder, double click hosts to open it.
Edit the HOSTS file and save your changes.
What If I Can’t Save the HOSTS File?
In some versions of Windows, you don’t have permission to save directly to the \etc\ folder. If this is the case, you might see an error like this one when you try to save:
Instead, you must save the file elsewhere like the Documents or Desktop folder. After saving, go to that folder, copy the HOSTS file, and paste it directly into the location where the HOSTS file should be (C:\Windows\System32\drivers\etc\). You’ll be prompted with permission validation and will have to confirm overwriting the file.
If you still have trouble saving the modified HOSTS file, check the file’s attributes to see if it’s been marked read-only. Right-click the file and select Properties to see the attributes.
Another option is to open your text editor program as an administrator so that the permissions are already applied to the editor. Then, saving the HOSTS file over the original can be performed without having to verify your admin credentials.
If you still can’t save to the HOSTS file location, you probably don’t have the correct permissions to be editing files in that folder. You should be logged in under an account that has administrative rights over the HOSTS file, which you can check by right-clicking the file and going to the Security tab.
What Is the HOSTS File Used For?
The HOSTS file is the virtual equivalent of a phone company’s directory assistance. Where directory assistance matches a person’s name to a phone number, the HOSTS file maps domain names to IP addresses.
Entries in the HOSTS file override DNS entries maintained by the ISP. While this hierarchy might come in handy for regular use, like to block ads or certain malicious IP addresses, its functions also make this file a common target of malware.
By modifying it, malware can block access to antivirus updates or force you to a malicious website. Thus, it’s a good idea to check the HOSTS file periodically or at least know how to remove false entries.
A much easier way to block certain domains from your computer is to use a custom DNS service that supports content filtering or blocklists.
How to Edit the Hosts File in Windows 10
There’s an easy way and a hard way to edit the hosts file in Windows 10. In this article, we’ll show you both.
If you’re a regular groovyPost reader, you know that DNS translates domain names like groovyPost.com into IP addresses like 104.24.11.25. But did you know that there’s a file on your Windows 10 PC that can override that? It’s called your hosts file and lets you map specific domain names to an IP address of your choosing. Your HOSTS file only affects your computer, so you can use it to create custom URLs for IP addresses on your network, or you can use it to redirect certain websites.
As you can imagine, editing the HOSTS file can easily break your internet if it’s modified incorrectly or maliciously. So, it’s not particularly easy for a normal user to edit. This is a good thing. But if you want to change your HOSTS file purposefully, here’s how.
Edit Your Windows 10 Host File as an Administrator
The HOSTS file is normally stored in a plain text file in the Windows System folder and can be modified for various use cases. One particular reason I edited the Host file in the past was to block certain websites when I imaged computers for a local high school. This was probably one of the best and easiest ways I could ensure students didn’t load any unauthorized websites such as Facebook or YouTube.
Editing your Windows Hosts file doesn’t have to feel like going down a rabbit hole. In Windows XP and earlier versions, the process was quite easy, add an exception to your antivirus, open it in Notepad, make your changes then save it.
In Windows 10, if you try to edit your hosts file, you’ll probably be able to open it just fine, but when you go to save it, you’ll get an error:
Here’s how you can edit your hosts file without getting the “You don’t have permission to save in this location. Contact the administrator to obtain permission” error.
Hit the start menu or press the Windows key and start typing Notepad.
Right-click Notepad and choose Run as administrator.
In Notepad, click File then Open… In the File name field, paste the following path in:
Now you’ll be able to edit and save changes to your HOSTS file.
To map a domain, add a line based on the examples in the HOSTS file.
Start with the target IP address, then a space, then the domain name. If you want to block a website, redirect it to 127.0.0.1.
Don’t put in the # if you want it to take effect.
Also, remember that www.youtube.com is different than youtube.com.
You may need to restart your computer for the new HOSTS file to take effect.
An Easier Way to Edit the Hosts File in Windows 10
If you found that process a bit cumbersome, there’s a third-party utility you can use to modify your HOSTS file. I found a good one called Hosts File Editor by Scott Lerch. Let’s take a look and see how it works.
Now that you know the basics, here’s how you do it using the app, HOSTS File editor.
Download the 1 MB installer, then proceed to set it up. Remember to choose the option just for yourself if you don’t want other users to access it.
Launch the app in Start > All apps—this will add the app to the Notification area, where you can launch the editor anytime you need to.
Hosts File Editor features a clean, easy-to-use interface. To begin using the program, populate the table with IP Addresses, Host Names, and comment on the websites you want to manage. It’s not just limited to popular Internet websites. Even devices on your home network with an IP address can be managed, so your Xbox, iPad, web cameras, or routers are much easier to block access to if needed.
When you are ready to block a website, check the box for the sites you want to prevent access to, click Save, and that’s it.
Another nice ease of use feature is the ability to right-click the Hosts File Editor in the Notification area, click Disable Hosts File, or make a quick edit. No need to go hunting or launch the command line anymore.
There are some other cool features included for power users and network administrators, such as:
So, there you have it, a quick and easy way to edit your Hosts File in Windows 10.
How to Edit Hosts File in Linux, Windows, or Mac
Home » SysAdmin » How to Edit Hosts File in Linux, Windows, or Mac
The hosts file in Windows, Mac, or Linux maps hostnames to IP addresses. For example, an intranet, like a corporate office that has servers for users to access, or it could be domain names for servers on the internet.
Editing your hosts file can be useful if you are running tests on your network. By mapping an IP address to a server name (or domain name), you can skip the process where a web browser uses a Domain Name Server(DNS) lookup to translate the domain name to the IP address.
In this tutorial, learn how to edit hosts file on Linux, Windows, or Mac.
How to Edit Linux Hosts File
Step 1: Open a Terminal Window (Command Line)
Most Linux distributions have an applications > utilities > terminal feature, or an option to right-click the desktop and click Open Terminal.
Step 2: Open the Linux Hosts File
To open the Linux hosts file, type the command:
Instead of Vim, you can use any other text editor, like nano.
The system should prompt for your password – enter it, and the Hosts file should open.
Step 3: Modify the File
The hosts file in Linux is formatted so that the IP address is first, and the server name is second.
Add any entries you wish to the end of the file. If you make a mistake or need to tell your operating system to ignore a line, add the ‘#’ sign at the beginning of that line.
Make sure you save the file in Vim before you exit!
Step 4 (Optional): Name Service Switch
The hosts file bypasses the standard Domain Name Server lookup. In Linux, there’s another file that tells the operating system what order to look for the IP address translations.
The file is nsswitch.conf, and if it’s configured to look at DNS first, then it’ll skip your hosts file and go straight to DNS lookup.
To check the configuration, in your terminal window type:
The terminal will return a list of information.
About halfway down, there should be an entry labeled “hosts”. Make sure that the right-hand column lists files first. If for some reason DNS is listed first, open the file in your text editor:
It should open the nsswitch.conf file. For the hosts: setting, change the entry so that files is at the beginning of the entry, and dns is at the end.
Note: Check out our tutorial Linux sed Command: How To Use the Stream Editor to learn how to edit lines in a Linux text file without a text editor.
How to Edit Hosts File in Windows
Step 1: Open Notepad as an Administrator
You’ll need administrator privileges for this operation.
Step 2: Open the Windows Hosts File
Step 3: Edit the File
The Windows hosts file is that it gives you a brief explanation of how to write a new line. Here’s a brief breakdown:
The first set of four (4) digits is the IP address you’re mapping. This could be the internal IP address of a server on the network, or it could be the IP address of a website.
The second label is the name you want to be able to type in a browser to access the server at the IP address you just specified.
Once you’re finished making your changes, save the file (File > Save) and exit.
If you make an edit to the hosts file and something stops working, you can tell Windows to ignore any line by putting a # sign at the beginning of that line.
It would look like:
How to Edit Mac Hosts File
Step 1: Open the Mac Terminal
Open the Finder, and go to Applications > Utilities > Terminal
Type the following in the terminal window:
The system should prompt you to enter your password – this is the same password you use to log in to the system. Type it in, and hit Enter.
Step 2: Edit Mac Hosts File
The IP address is first, and the server name comes second. Comments are indicated with a ‘#’ sign. Consider the example below:
Enter the IP address you want to refer to first, hit space, and then the server name (or domain name) that you want to associate with it.
If you make a mistake, you can tell Mac OS to ignore a line by typing a # at the beginning of that line.
Save your changes by pressing Command + O, then exit by pressing Command + X.
Editing the hosts file in Windows, Mac, or Linux operating system is a simple task.
It’s especially handy that the file looks the same, no matter which you’re running! Just make sure you know the IP address of the server you want to connect to, and then specify the name you want to type into a browser, and you’ll be on your way!
Источники информации:
- http://support.microsoft.com/en-us/topic/how-to-reset-the-hosts-file-back-to-the-default-c2a43f9d-e176-c6f3-e4ef-3500277a6dae
- http://www.lifewire.com/how-to-edit-the-hosts-file-153661
- http://www.groovypost.com/howto/edit-hosts-file-windows-10/
- http://phoenixnap.com/kb/how-to-edit-hosts-file-in-windows-mac-or-linux