前端analysis | 3w & 1h

《DNS》- DNS污染HomeBrew失败

2020-12-25

背景

1
2
Installing Homebrew...
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

DNS污染
Dns 解析ip失败

怎么验证是否遭遇DNS污染?

1.点“开始”-“运行”-输入CMD,再输入 ipconfig /all ,在下“DNS SERVER”里找到你使用的DNS服务器地址。

2.再输入 nslookup http://idcbest.com(你的域名) 你的DNS服务器IP ,来查看是否能解析。

3.再输入 nslookup http://idcbest.com 8.8.8.8 使用Google的DNS服务器验证。

域名遭遇DNS污染怎么解决?

1.更换DNS解析服务器。一般来说,域名注册商家都是提供免费的DNS解析服务的,以我所实用的新之洲数据为例,就提供了许多免费的DNS解析服务,而且解析速度很快,比之前实用的什么万网之流要快得多,不可能全部被污染,所以更换两个DNS服务器即可。

2.使用第三方DNS解析服务。目前有很多第三方网站提供DNS解析服务,不少都是免费的,国内也有免费提供DNS解析服务的,使用第三方DNS服务可以部分解决问题,比如新之洲数据正在使用的DNSpod服务,就是国内还算比较稳定的DNS解析服务。

注意事项一:在换用第三方解析服务的时候,应该先到DNSPOD之类的解析服务商那里将域名解析,过几个小时再到新之洲数据之类的域名注册商那里去修改DNS服务器,这样可以避免博客出现因解析时间造成的空白期。

注意事项二:Godaddy目前本身域名就被DNS污染了,即使挂VPN也访问不了,只有更改自己电脑的DNS(比如改成google的8.8.8.8)才能访问。

3.搭建自己的DNS服务器。这样子最保险,当然也最是费时废财,有条件的朋友可以尝试。

解决方案

https://www.ipaddress.com/ 查看ip

配置host

在本机的 host 文件中添加,建议使用 switchhosts 方便 host 管理

1
2
3
4
199.232.68.133 raw.githubusercontent.com
199.232.68.133 user-images.githubusercontent.com
199.232.68.133 avatars2.githubusercontent.com
199.232.68.133 avatars1.githubusercontent.com

添加以上几条 host 配置,页面的图片展示就正常了,homebrew 也能装了,nvm 也行动灵活了。

HomeBrew

1
2
3
4
5
6
# 安装 
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# 卸载
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

shallow Clone

clone 仅仅拉取最新的commits,

1
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
1
2
3
4
git clone -–depth [depth] [remote-url]

git clone [remote-url] --branch [name] --single-branch [folder]

ssl问题

解决方案

1
2
3
4
5
#latest
brew install curl-openssl

#older
brew reinstall curl --with-openssl
1
2
3
4
5
6
If you need to have python@3.9 first in your PATH run:
echo 'export PATH="/usr/local/opt/python@3.9/bin:$PATH"' >> ~/.zshrc

For compilers to find python@3.9 you may need to set:
export LDFLAGS="-L/usr/local/opt/python@3.9/lib"

mac cli展示颜色

1
2
3
4
5
vim ~/.bash_profile

export CLICOLOR=1
export LSCOLORS=ExGxFxdaCxDaDahbadeche

参考

raw.githubusercontent.com

使用支付宝打赏
使用微信打赏

若你觉得我的文章对你有帮助,欢迎点击上方按钮对我打赏