Меню Рубрики

How to edit hosts file windows

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 purposefully change your HOSTS file, 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 a variety of 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, just 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, simply 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 have access to it.

Launch the app in Start > All apps—this will add the app to the Notification area where 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 a 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 simply right click the Hosts File Editor in the Notification area then 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:

  • Cut, copy, paste, duplicate, enable, disable and move one or more entries at a time.
  • Filter and sort when there are a large number of host entries
  • Archive and restore various hosts file configurations when switching between environments
  • Automatically ping endpoints to check availability

So, there you have it, a quick and easy way to edit your Hosts File in Windows 10.

Источник

How to Edit the HOSTS File in Windows

Customize your network settings in Windows 10, 8, or 7

The Windows HOSTS file functions like a local copy of a DNS server, so knowing how to edit it might come in handy if you want to make custom domain redirects, block websites, or remove malicious entries set by malware. That said, you might run into permission errors and other problems when you make changes to this file in some versions of Windows.

The instructions in this article apply to Windows XP, Windows 7, Windows 8, and Windows 10.

How to Edit the Windows HOSTS File

In Windows 7, 8, and 10, 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.

This step is required because the HOSTS file doesn’t have the .TXT file extension.

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

Can be useful for anyone in IT

The hosts file is a text-based file located in the same place in all modern Windows versions. Most people don’t ever need to get into it, but if you do, you’ll need to know how to open and edit the hosts file.

However, in some versions of Windows, editing the hosts file directly isn’t allowed. In fact, you’ll get an error if you try to save the changes. Fortunately, there’s a simple tip you can use to edit the hosts file in Windows 10, 8, 7, Vista, or XP.

What Does The Hosts File Do?

The purpose of the hosts file was originally to be what DNS servers do now – map friendly domain names to unfriendly IP addresses.

It’s much easier to remember a domain name like YouTube.com than an IP address like 172.217.1.238. Instead of having to type the IP address into the address bar each time you want to watch YouTube videos, you can just enter the domain name, and the DNS server your device is using will map the name to the right address so you can get to the webpage a lot easier.

The hosts file, since it serves as a sort of DNS server, works the same way. You can enter an IP address that a domain name should be resolved to. In other words, you could order your computer to load a different IP address than the DNS server would, essentially letting you do a few cool things.

Why Edit The Hosts File?

One reason to edit the hosts file is if you want a super basic way to block websites from loading on your computer. Enter an invalid or wrong IP address for the site you want to block, and each time you try accessing it, the hosts file will load the IP address you chose. Depending on what you picked, it might completely block the website.

You can use the same technique to make the hosts file block malicious sites. There are even lists of hosts file entries (such as this one) you can download and import into your hosts file to block hundreds of malicious sites or ads.

Another use for the hosts file is to speed up your web browsing. If the DNS server you’re using is down or not working quickly enough, manually entering the IP address and domain name mappings in your hosts file lets your computer find those addresses nearly instantly instead of relying on the DNS server.

Tip: Learn how to use alternate DNS servers to get faster internet access.

Windows Hosts File Location

You need to know where to go to find the hosts file before you can open it for editing. This is the hosts file location in Windows 10 through Windows XP:

C:\Windows\system32\drivers\etc

How To Edit The Hosts File

The hosts file is a text file, meaning that you need a text editor to make changes to it. However, since the hosts file is super basic and doesn’t need to deal with hyperlinks, images, etc., you can use a basic text editor (i.e., there’s no need to use a full-fledged editor like Microsoft Word).

Opening The Hosts File

Let’s start with simply opening the hosts file. We’ll use Notepad, which is built into Windows 10 down through Windows XP.

  • Open the Run dialog box by holding down the Windows key and then pressing R once.
  • Type notepad and then press Enter to open the program.

  • Go to File >Open.
  • In the file name text box at the bottom, type (or copy and paste) the hosts file location shown above and then press Enter.

  • Select the menu to the right of the text box to change Text Documents (*.txt) to All Files (*).

  • Double-click hosts from the list of files to open the hosts file for editing in Notepad.

Editing The Hosts File

There are a few examples in the hosts file to show you how to format your entries. You have to put the IP address first followed by the domain name, and the two have to be separated by at least one space (a tab is a good way to format them).

Here are some examples:

127.0.0.1 www.google.com
13.249.79.104 www.bing.com

As you can see in the image above and read from the directions in the hosts file, the # symbol is used as a comment, meaning that anything that follows it is avoided. This is why the two example lines we give above are useful in this hosts file; they’re not being followed by that symbol.

If you want to block websites with the hosts file, such as YouTube, Amazon, Google, Reddit.com, etc., you can enter a false IP address like 0.0.0.0.

Note: When you enter the URL of the site you want to associate with a specific IP address, be sure to exclude the beginning part and only type the subdomain, such as www or whatever it happens to be for the site you’re adding.

Saving The Hosts File

Here’s how we’ll save the hosts file to make sure it works no matter which operating system you use, which text editor you picked, or how your Windows settings are configured:

  • Go to File >Save As.
  • Change the Save as type option to All Files (*).
  • Rename the file to hosts.backupfile, and then save it to your desktop.

  • Close Notepad and then find the hosts file you just created on the desktop. You want to delete the .backupfile part of the name and leave only hosts (with no period or text after the word).

  • After you do that, click away from the file to something else on the desktop, and confirm the name change when asked.
  • Copy the hosts file.
  • Open the hosts file location you had open before (the etc folder).
  • Paste the hosts file you copied from the desktop, and confirm any overwrite prompts if you see them.

Founder of Help Desk Geek and managing editor. He began blogging in 2007 and quit his job in 2010 to blog full-time. He has over 15 years of industry experience in IT and holds several technical certifications. Read Aseem’s Full Bio

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

  • How to disable disk checking windows 10
  • How to disable autoupdate windows 10
  • How to destroy windows
  • How to customize windows 10
  • How to connect windows 7 to bluetooth