在Windows 10中如何修改本地域名

Windows系统本地域名配置文件hosts位于目录C:\Windows\System32\drivers\etc中,其内容大致如下所示:

# 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

这里,我们向其中添加如下一行记录,代表将域名vm200.lan指向IP地址223.6.6.6,即

# 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

223.6.6.6		vm200.lan

通常情况下,系统盘(C:)中的文件对于普通用户仅仅有只读权限,本地域名配置文件hosts即是如此,如果要编辑文件内容,需要修改文件的权限,以hosts为例,修改步骤如下图所示。

修改完成后,可以打开命名行终端用ping命令验证结果,即

Microsoft Windows [Version 10.0.18362.30]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\lwk>ping vm200.lan

Pinging vm200.lan [223.6.6.6] with 32 bytes of data:
Reply from 223.6.6.6: bytes=32 time=10ms TTL=63
Reply from 223.6.6.6: bytes=32 time=8ms TTL=63
Reply from 223.6.6.6: bytes=32 time=8ms TTL=63
Reply from 223.6.6.6: bytes=32 time=12ms TTL=63

Ping statistics for 223.6.6.6:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 8ms, Maximum = 12ms, Average = 9ms

C:\Users\lwk>

如图所示,这里的修改就生效了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章