如何在 Windows 10 中编辑主机文件:(How to Edit the Hosts File in Windows 10:) “主机”文件是一个纯文本文件,它将主机名映射到 IP 地址。主机文件有助于寻址计算机网络中的网络节点。主机名是分配给网络上的设备(主机)的易于理解的名称或标签,用于区分特定网络或 Internet 上的一个设备与另一个设备。要在 IP 网络中定位主机,我们需要它的 IP 地址。主机文件通过将主机标签与其实际 IP 地址相匹配来提供服务。
为什么您的计算机需要 hosts 文件?(Why is hosts file needed in your computer?)
例如,我们使用的www.google.com是我们用来访问该网站的主机名。但是在网络中,站点使用数字地址(例如 8.8.8.8)定位,这些地址称为 IP 地址。使用主机名是因为实际上不可能记住所有站点的 IP 地址。因此,每当您在浏览器中键入任何主机名时,首先使用主机文件将其映射到其 IP 地址,然后访问该站点。如果此主机名在 hosts 文件中没有映射,您的计算机将从DNS服务器(域名服务器)获取其 IP 地址。拥有主机文件可以减少用于查询DNS的时间(DNS)并在每次访问站点时收到其响应。此外,hosts 文件中包含的映射会覆盖从DNS服务器检索的数据。
如何修改hosts文件供自己使用?(How to modify hosts file for your own use?)
编辑主机文件是可能的,您可能出于各种原因需要这样做。
- 您可以通过在将网站 IP 地址映射到您自己选择的主机名的主机文件中添加所需条目来创建网站快捷方式。
- 您可以通过将其主机名映射到您自己计算机的 IP 地址 127.0.0.1(也称为环回 IP 地址)来阻止任何网站或广告。
如何在 Windows 10 中编辑主机文件(How to Edit the Hosts File in Windows 10)
确保 创建一个还原点(create a restore point) 以防万一出现问题。
hosts 文件位于计算机上的C:\Windows\system32\drivers\etc\hosts 。(on your computer. )由于它是纯文本文件,因此可以在记事本中打开和编辑。因此,不要浪费任何时间,让我们在下面列出的教程的帮助下看看如何在 Windows 10 中编辑主机文件。(How to Edit the Hosts File in Windows 10)
在 Windows 8 和 Windows 10 上编辑主机文件(Edit the Hosts File on Windows 8 and Windows 10)
1. 按Windows Key + S调出Windows 搜索(Windows Search)框。
2.输入记事本(notepad),在搜索结果中,您将看到记事本的快捷方式。(shortcut for Notepad.)
3. 右键单击记事本(Notepad)并从上下文菜单中选择“以管理员身份运行”。(Run as administrator)
4. 将出现提示。选择是(Yes)继续。
5.将出现记事本(Notepad)窗口。 从菜单(Menu)中选择文件(File)选项,然后单击“打开(Open)”。
6. 要打开 hosts 文件,请浏览至C:\Windows\system32\drivers\etc.
7. 如果您在此文件夹中看不到 hosts 文件,请在下面的选项中选择“所有文件(All Files)”。
8. 选择主机文件(hosts file),然后单击打开。(Open.)
9. 您现在可以看到 hosts 文件的内容。
10. 在 hosts 文件中修改或进行所需的更改。
11. 从记事本菜单转到 File > Save或按Ctrl+S to save the changes.
注意:(Note:)如果您在没有选择“以管理员身份运行”(Run as administrator)的情况下打开记事本,您将收到如下错误消息:(an error message like this:)
(Edit the Hosts File o)在Windows 7 和 Vista(n Windows 7 and Vista)上编辑主机文件
- 单击开始按钮。(Start button.)
- 转到“所有程序(All Programs)”,然后转到“附件(Accessories)”。
- 右键单击记事本并选择“以管理员身份运行(Run as administrator)”。
- 出现提示。点击继续。(Continue.)
- 在记事本中,转到文件(File),然后打开。(Open.)
- 从选项中选择“所有文件”。(All Files)
- 浏览到C:\Windows\system32\drivers\etc 并打开 hosts 文件。(and open the hosts file.)
- 要保存任何更改,请转到File > Save or press Ctrl+S.
(Edit the Hosts File o)在Windows NT、Windows 2000 和 Windows XP(n Windows NT, Windows 2000, and Windows XP)上编辑主机文件
- 单击开始按钮。
- 转到“所有程序”,然后转到“附件”。
- 选择记事本。( Notepad.)
- 在记事本中,转到文件(File),然后打开。(Open.)
- 从选项中选择“所有文件”。(All Files)
- 浏览到C:\Windows\system32\drivers\etc 并打开 hosts 文件。(and open the hosts file.)
- 要保存任何更改,请转到File > Save或按 Ctrl+S。
在 hosts 文件中,每一行都包含一个条目,它将 IP 地址映射到一个或多个主机名。在每一行中,IP 地址首先出现,然后是空格或制表符,然后是主机名。假设(Suppose)您希望 xyz.com 指向 10.9.8.7,您将在文件的新行中写入“10.9.8.7 xyz.com”。
使用第三方应用程序编辑主机文件(Edit the Hosts File using Third Party Apps)
编辑主机文件的更简单方法是使用第三方应用程序,它为您提供更多功能,如阻止站点、排序条目等。其中两个软件是:
主机文件编辑器(HOSTS FILE EDITOR)
您可以使用此软件轻松管理您的主机文件。除了编辑 hosts 文件外,您还可以一次复制、启用、禁用一个或多个条目,过滤和排序条目,归档和恢复各种 hosts 文件配置等。
它为您的主机文件中的所有条目提供了一个表格界面,其中包含 IP 地址、主机名和注释列。您可以通过右键单击通知中的主机文件编辑器(File Editor)图标来启用或禁用整个主机文件。
主持人(HOSTSMAN)
HostsMan是另一个免费软件应用程序,可让您轻松管理主机文件。它的功能包括内置主机文件更新器、启用或禁用主机文件、扫描主机以查找错误、重复和可能的劫持等。
如何保护您的(How to protect your )主机文件?( file?)
有时,恶意软件会使用 hosts 文件将您重定向到包含恶意内容的不安全、不需要的站点。hosts 文件可能会受到病毒、间谍软件(Spyware)或木马(Trojans)程序的损害。为了保护您的 hosts 文件不被某些恶意软件编辑,
1.转到文件夹C:\Windows\system32\drivers\etc.
2.右键单击hosts文件并选择属性。(2.Right click on the hosts file and select properties.)
3.选择“只读”属性并单击应用。(3.Select ‘Read-only’ attribute and click on Apply.)
现在您只能编辑主机文件、屏蔽广告、创建自己的快捷方式、将本地域分配给您的计算机等。
受到推崇的:(Recommended:)
我希望上述步骤对您有所帮助,现在您可以轻松地 在 Windows 10 中编辑主机文件,(Edit the Hosts File in Windows 10) 但如果您对本指南仍有任何疑问,请随时在评论部分提出。
How to Edit the Hosts File in Windows 10 [GUIDE]
How to Edit the Hosts File in Windows 10: A ‘hosts’ file is a plain text file, which maps hostnames to IP addresses. A host file helps in addressing network nodes in a computer network. A hostname is a human-friendly name or label assigned to a device (a host) on a network and is used to distinguish one device from another on a specific network or over the internet. To locate a host in an IP network, we need its IP address. A hosts file serves by matching the host label to its actual IP address.
Why is hosts file needed in your computer?
The www.google.com we use, for instance, is a hostname that we use to access the site. But in a network, sites are located using numerical addresses like 8.8.8.8 which are called IP addresses. Hostnames are used because it is not practically possible to remember the IP addresses of all the sites. So, whenever you type any hostname in your browser, the hosts file is first used to map it to its IP address and then the site is accessed. If this hostname does not have a mapping in the hosts file, your computer fetches its IP address from a DNS server (domain name server). Having a hosts file eases up the time used to query a DNS and receive its response every time a site is being accessed. Also, the mappings contained in the hosts file to override the data retrieved from a DNS server.
How to modify hosts file for your own use?
Editing a hosts file is possible and you might need to do it for a variety of reasons.
- You can create website shortcuts by adding a required entry in the hosts file that maps the website IP address to a hostname of your own choice.
- You can block any website or ads by mapping their hostname to the IP address of your own computer which is 127.0.0.1, also called loopback IP address.
How to Edit the Hosts File in Windows 10
Make sure to create a restore point just in case something goes wrong.
The hosts file is located at C:\Windows\system32\drivers\etc\hosts on your computer. Since it is a plain text file, it can be opened and edited in notepad. So without wasting any time let’s see How to Edit the Hosts File in Windows 10 with the help of the below-listed tutorial.
Edit the Hosts File on Windows 8 and Windows 10
1. Press Windows Key + S to bring up the Windows Search box.
2. Type notepad and in the search results, you will see a shortcut for Notepad.
3. Right-click on Notepad and select ‘Run as administrator’ from the context menu.
4. A prompt will appear. Select Yes to continue.
5. Notepad window will appear. Select File option from the Menu and then click on ‘Open‘.
6. To open the hosts file, browse to C:\Windows\system32\drivers\etc.
7. If you can’t see the hosts file in this folder, select ‘All Files’ in the option below.
8. Select the hosts file and then click on Open.
9. You can now see the contents of the hosts file.
10. Modify or make the required changes in the hosts file.
11. From Notepad menu go to File > Save or press Ctrl+S to save the changes.
Note: If you had opened the notepad without selecting ‘Run as administrator’, you would have got an error message like this:
Edit the Hosts File on Windows 7 and Vista
- Click on the Start button.
- Go to ‘All Programs’ and then ‘Accessories’.
- Right-click on Notepad and select ‘Run as administrator’.
- A prompt appears. Click on Continue.
- In notepad, go to File and then Open.
- Select ‘All Files’ from the options.
- Browse to C:\Windows\system32\drivers\etc and open the hosts file.
- To save any changes, go to File > Save or press Ctrl+S.
Edit the Hosts File on Windows NT, Windows 2000, and Windows XP
- Click on the Start button.
- Go to ‘All Programs’ and then ‘Accessories’.
- Select Notepad.
- In notepad, go to File and then Open.
- Select ‘All Files’ from the options.
- Browse to C:\Windows\system32\drivers\etc and open the hosts file.
- To save any changes, go to File > Save or press Ctrl+S.
In the hosts file, each line contains one entry which maps an IP address to one or more hostnames. In each line, IP address comes first, then followed by space or tab character and then the hostname(s). Suppose you want xyz.com to point to 10.9.8.7, you will write ’10.9.8.7 xyz.com’ in the new line of the file.
Edit the Hosts File using Third Party Apps
A more simple way to edit hosts file is to use third party applications which give you more features like blocking sites, sorting entries, etc. Two of such softwares are:
HOSTS FILE EDITOR
You can easily manage your hosts file with this software. Apart from editing the hosts file, you can duplicate, enable, disable one or more entries at a time, filter and sort entries, archive and restore various hosts file configurations, etc.
It gives you a tabular interface for all the entries in your hosts file, with columns IP address, hostname as well as comment. You can enable or disable entire hosts file by right clicking on Hosts File Editor icon in the notification.
HOSTSMAN
HostsMan is another freeware application that lets you manage your hosts file with ease. Its features include built-in hosts file updater, enable or disable hosts file, Scan hosts for errors, duplicates and possible hijacks, etc.
How to protect your hosts file?
Sometimes, malicious software use the hosts file to redirect you to unsafe, unwanted sites containing malicious content. The hosts file can be harmed by Viruses, Spyware or Trojans. In order to protect your hosts file from being edited by some malicious software,
1.Go to the folder C:\Windows\system32\drivers\etc.
2.Right click on the hosts file and select properties.
3.Select ‘Read-only’ attribute and click on Apply.
Now you can only edit your hosts files, block ads, create your own shortcuts, assign local domains to your computers, etc.
Recommended:
I hope the above steps were helpful and now you can easily Edit the Hosts File in Windows 10 but if you still have any questions regarding this guide then feel free to ask them in the comment’s section.