macOS、windows系统的配置方式一样,只不过是 hosts 文件路径不一样。
windows系统路径:C:\Windows\System32\drivers\etc
操作步骤
1、进入 /etc 目录
cd ----
2、vim 打开 hosts 文件,
vim -----
3、按下 i 键,表示 insert 内容,在文件尾部添加你所要映射的域名。示例:百度
# 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
127.0---- -------------
4、保存并推出文件:先按 esc 按键,再输入下面命令符,然后回车
---