dns中的主机记录_在Windows 10教程中修改主机文件以添加和更改DNS记录

  • Post author:
  • Post category:其他


dns中的主机记录

dns中的主机记录

DNS makes us name IP addresses into meaningful names. We can name a host with a human-readable name and use this name to access it. DNS management can be done in different ways where DNS servers are the most practical and straightforward way. But the first step before a DNS server to query a DNS is using the local

Hosts File

. In this tutorial, we will learn how to manage Windows 10 Hosts File like change, secure, restore, block, etc. These settings can be also applied to all modern Windows operating systems like Windows 7, Windows 8, Windows 10, Windows Server 2008, Windows Server 2012, Windows Server 2016, Windows Server 2019.

DNS使我们将IP地址命名为有意义的名称。 我们可以使用易于理解的名称来命名主机,然后使用该名称进行访问。 DNS管理可以以不同的方式完成,而DNS服务器是最实用,最直接的方式。 但是,DNS服务器查询DNS之前的第一步是使用本地

Hosts File

。 在本教程中,我们将学习如何管理Windows 10主机文件,例如更改,安全,还原,阻止等。这些设置也可以应用于所有现代Windows操作系统,例如Windows 7,Windows 8,Windows 10,Windows Server 2008 ,Windows Server 2012,Windows Server 2016,Windows Server 2019。

什么是主机文件?

(

What Is Hosts File?

)


hosts

file is a basic text file that stores IP address and domain name matches. Every IP address has a domain name that should be compliant with the domain name standard.

hosts

file usage is very popular and standard where it is used different operating systems like Microsoft Windows, Linux Distributions and MacOSX operating systems.


hosts

文件是一个基本的文本文件,用于存储IP地址和域名匹配项。 每个IP地址都有一个域名应符合域名标准。

hosts

文件的使用非常流行并且是标准的,用于不同的操作系统,例如Microsoft Windows,Linux Distributions和MacOSX操作系统。

主机文件位置

(

Hosts File Location

)

The hosts file is stored in different paths in different operating systems. The hosts file is generally stored in a system configuration path or location which requires special privileges like Administrator to access and change it. In Windows operating systems hosts file is store

C:\Windows\System32\Drivers\etc\

file as it can be also expressed like

%WinDir%\System32\Drivers\Etc\

where

%WinDir%

is the path variable which stores windows installation path.

主机文件存储在不同操作系统中的不同路径中。 主机文件通常存储在系统配置路径或位置中,该路径或位置需要特殊权限(例如管理员)才能访问和更改。 在Windows操作系统中,主机文件存储在

C:\Windows\System32\Drivers\etc\

文件中,因为它也可以表示为

%WinDir%\System32\Drivers\Etc\

,其中

%WinDir%

是存储Windows安装路径的路径变量。

Hosts File Location
Hosts File Location
主机文件位置

Also, we can see that its size is 1KB where it stores very little data in text format.

此外,我们可以看到它的大小为1KB,其中以文本格式存储的数据很少。

主机文件语法

(

Hosts File Syntax

)

As stated previously hosts file has very basic syntax. Each line is an entry to match the IP address with the domain name.

如前所述,hosts文件具有非常基本的语法。 每行是一个将IP地址与域名匹配的条目。

IP_ADDRESS DOMAN_NAME
  • `IP_ADDRESS` is the IP address we want to route for the given DOMAIN_NAME

    IP_ADDRESS是我们要为给定DOMAIN_NAME路由的IP地址

  • `DOMAIN_NAME` is the domain name we want to match with the IP_ADDRESS

    DOMAIN_NAME是我们要与IP_ADDRESS匹配的域名

# Copyright (c) 1993-2009 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 handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost

主机文件注释

(

Hosts File Comment

)

In hosts file

#

sign is used to create comments. Comments are useful to create some notes or explanations about the given DNS record. We can also use comments in order to make an active record passive. In the following example, the

poftut.com

domain name will be redirected to the IP address

1.2.3.4

.

在主机文件中,使用

#

号创建注释。 注释对于创建有关给定DNS记录的一些注释或解释很有用。 我们还可以使用注释来使活动记录成为被动记录。 在以下示例中,

poftut.com

域名将被重定向到IP地址

1.2.3.4

# This is poftut.com special DNS record

1.2.3.4 poftut.com

If we want to make this record passive without deleting it we can put a

#

before the poftut.com record to make it passive.

如果要使该记录成为被动记录而不删除它,我们可以在poftut.com记录前加上

#

以使其成为被动记录。

# This is poftut.com special DNS record

#1.2.3.4 poftut.com

备份主机文件

(

Backup Hosts File

)

Before starting the adding, remo