windows 设置修改本地 hosts 访问 github 快速访问 提高访问 github 速度

获取IP地址

查询 以下域名IP地址

  • github.com
  • github.global.ssl.fastly.net
  • assets-cdn.github.com

通过在线网址查询:https://websites.ipaddress.com/ 或 http://tool.chinaz.com/dns/

 

 

 

 前面两个地址都是一个 IP地址,最后一个是四个

记录如下

140.82.114.4 github.com
185.199.110.153 assets-cdn.github.com
185.199.108.153 assets-cdn.github.com
185.199.109.153 assets-cdn.github.com
185.199.111.153 assets-cdn.github.com
199.232.69.194 github.global.ssl.fastly.net
 
 

设置hosts

windows hosts 文件路径: C:\Windows\System32\drivers\etc

通过记事本或编辑器打开 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 host

# localhost name resolution is handled within DNS itself.
#    127.0.0.1       localhost
#    ::1             localhost
140.82.114.4 github.com
185.199.110.153 assets-cdn.github.com
185.199.108.153 assets-cdn.github.com
185.199.109.153 assets-cdn.github.com
185.199.111.153 assets-cdn.github.com
199.232.69.194 github.global.ssl.fastly.net

打开 cmd 刷新本地dns

ipconfig /flushdns

使用浏览器访问

每次更新 hosts 过后好像不能立马生效,测试都是等了好一会儿才可以,大概几分钟的样子。

尝试用 Google Chrome 访问,一直访问失败,但是使用 Microsoft Edge 访问成功了。或许和之前使用的一个软件修改了谷歌浏览器的什么配置有关。

IP地址会变,如果不能访问了,尝试重新获取IP地址,再修改。

快速访问 GitHub

http://tool.chinaz.com/dns/ 查询出来的地址是其他映射到 github 的地址

可以查询出来过后通过 ping IP 的方式,看看哪一个响应比较快,然后把 hosts 里面  github.com 改到对应 IP

更详细的解决方法、自动修改hosts...

参见 GitHub - 521xueweihan/GitHub520: 让你“爱”上 GitHub,解决访问时图裂、加载慢的问题。(无需安装)

原文地址:https://www.cnblogs.com/jiayouba/p/15602175.html