解决在hexo上github推送连接失败的问题

在国内,有时候使用 git clone 的速度实在太慢而让人难以承受,或者 git pull/git push 一点反应都没有,这里整理了一下解决方法,亲测有效。
总的来说,这是因为 github.global.ssl.fastly.net 域名被限制了。只要找到这个域名对应的 ip 地址,然后在 hosts 文件中加上 ip–>域名 的映射,刷新 DNS 缓存便可。

1.查找域名对应的 ip 地址

  • 在网站 https://www.ipaddress.com/ 分别搜索 github.global.ssl.fastly.net 和 github.com

  • 或者在本地的终端中如下键入:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    $ nslookup github.global.ssl.fastly.Net
    Server: 127.0.0.53
    Address: 127.0.0.53#53

    Non-authoritative answer:
    Name: github.global.ssl.fastly.Net
    Address: 151.101.229.194

    $ nslookup github.com
    Server: 127.0.0.53
    Address: 127.0.0.53#53

    Non-authoritative answer:
    Name: github.com
    Address: 13.229.188.59
  1. 修改 hosts 文件
  • Windows 上的 hosts 文件路径在: C:\Windows\System32\drivers\etc\hosts
    在 hosts 文件末尾添加两行
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    # 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

    199.232.69.194 github.global.ssl.fastly.net
  • Linux 的 hosts 文件路径在 /etc/hosts 中:
    1
    $ sudo vim /etc/hosts
  1. 刷新 DNS 缓存
  • windows
    1
    ipconfig /flushdns
  • linux
    1
    $ sudo /etc/init.d/networking restart
  1. 参考文献
    解决linux上git clone速度慢的问题
    git clone速度太慢的解决办法
  2. 本文转载自
    解决 GitHub 的 host 域名被限制的问题
-------------本文已结束赏个小钱吧-------------
×

感谢您的支持,我们会一直保持!

扫码支持
请土豪扫码随意打赏

打开微信扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

64.7K