centos 配置github加速

cdn加速

通过修改系统hosts文件的办法,绕过国内dns解析,直接访问GitHub的CDN节点,从而达到github访问加速的目的。不需要海外的服务器辅助。

GitHub在国内访问速度慢的问题原因有很多,但最直接和最主要的原因是GitHub的分发加速网络的域名遭到dns污染,下载网站上任何东西的时候会下半天,有时还会失败需要从头再来,多失败了几次又因访问次数过多被做了ip限制,让人恼火

做到以上需要三步

  1. 获取GitHub官方CDN地址
  2. 修改系统Hosts文件
  3. 刷新系统DNS缓存

1. 获取GitHub官方CDN地址

首先,打开

https://www.ipaddress.com/

查询以下三个链接的DNS解析地址

  1. github.com
  2. assets-cdn.github.com
  3. github.global.ssl.fastly.net
    image-20220415135630207.png

2. 修改系统Hosts文件

接着,打开系统/etc下的hosts文件,需要切入到root用户修改

# 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.113.3    github.com
185.199.108.153 assets-cdn.github.com
199.232.69.194  github.global.ssl.fastly.net

并在末尾添加三行记录并保存。(需管理员权限,注意IP地址与域名间需留有空格)

对于ubuntu系统,修改完hosts文件执行如下命令:

sudo /etc/init.d/network-manager restart

3. 刷新系统DNS缓存

运行 ipconfig /flushdns 手动刷新系统DNS缓存。

mac系统修改完hosts文件,保存并退出就可以了.不要要多一步刷新操作.
centos系统执行/etc/init.d/network restart命令 使得hosts生效

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 作为笔记收藏,原文链接。 加速国内Github访问1 获取GitHub官方CDN地址2 修改系统Hosts文件3 ...
    dantes1844阅读 841评论 0赞 9
  • 由于某些原因,国内访问Github会异常缓慢,在clone仓库时甚至只有10k以下的速度,下载半天有时还会失败需要...
    printf200阅读 61,651评论 17赞 97
  • 由于某些原因,国内访问Github会异常缓慢,在clone仓库时甚至只有10k以下的速度,下载半天有时还会失败需要...
    一条IT阅读 11,112评论 13赞 395
  • 由于某些原因,国内访问Github会异常缓慢,在clone仓库时甚至只有10k以下的速度,下载半天有时还会失败需要...
    张明洋_4b13阅读 540评论 0赞 0
  • 给国内访问Github加速 获取GitHub官方CDN地址 https://www.ipaddress.com/ ...
    小土豆dy阅读 14,237评论 17赞 113

友情链接更多精彩内容