修改 hosts

不会牛逼操作

-1. 位置、格式

所有系统都差不多,都是 啥啥/etc/hosts 这样的 .

具体去查即可 .

格式:

ip + 域名

域名不能含有通配符

hosts 可以绕过 dns 解析,直接访问 cdn 节点

0. 注释

# 后面的一行都是注释,有点像 Python .

或许注释只能放在每行开头?存疑

没有多行注释

1. 禁止访问

127.0.0.1 + 网址 或者 0.0.0.0 + 网址 .

可以防颓

2. 加速访问

首先搞到你要加速的网站的 ip 地址(可以 ipaddress),然后

ip + 域名

即可 .

3. 刷新

注意做完操作时候还要刷新网络:

  • Windows: ipconfig /flushdns
  • Linux: sudo /etc/init.d/networking restart

注意项总结

  • 域名不能含有通配符
  • 注释只能单行写
  • 操作完刷新网络
  • 如果有用杀毒软件的话杀软可能会只读 hosts 文件,把杀软关了就好了 .

附录 - Windows 下的 hosts

最后附一个 Windows 的初始 hosts 文件

# 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 hiost

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost

妈呀全是注释

posted @ 2022-01-23 08:41  Jijidawang  阅读(289)  评论(0编辑  收藏  举报
😅​