个人知识库
Author: 刘杰文, Date: 2023-04-16 13:51:55 +0800, Categories: , Tags: server blockedgeneralconnectioncn
[toc]
Note: The first one will block the results of some forbidden websites, like google.com. It’s best to use the second one.
查到IP后使用ping
检验一下是否真的能联通。如果可以,添加到本地DNS:
以管理员身份运行cmd.exe (或powershell).
cd %SystemRoot%/system32/drivers/etc
存档、修改和备份hosts文件
mkdir repo
如果旧的没备份,那么建议备份一下。可以按照第三步来备份。
修改
call notepad.exe hosts
创建对应时间的文件夹
手动方案(最简单)
mkdir repo\[日期]
copy hosts repo\[日期]\hosts
自动-方案1(最精细、自动化)
ps. 可以改用Powershell提到效率,只需稍微改改命令
for /f "delims=" %i in ('powershell -command "get-date -format o | foreach {$_ -replace \":\",\".\"}" ') do (set timestamp=%i)
mkdir repo\%timestamp%
copy hosts repo\%timestamp%\hosts
自动-方案2(最简洁、自动化)
ps. 可以改用Powershell提到效率,只需稍微改改命令
for /f "delims=" %i in ('powershell -command "get-date -uformat \"%Y-%m-%d\"') do (set timestamp=%i)
mkdir repo\%timestamp%
copy hosts repo\%timestamp%\hosts
自动-方案3(最高效、自动化)
for /f %i in ("%DATE%") do (set timestamp=%i)
mkdir "repo\%timestamp%"
copy hosts "repo\%timestamp%\hosts"
顺手刷新dns缓存:ipconfig /flushdns
完成。注意,一定要通过修改hosts的方式,通过浏览器插件重定向到IP大概率是不行的。
以下展现效果:
repo\20230407\hosts
repo\2023-04-11T21.36.24.4128152+08.00\hosts
repo\2023-04-11\hosts
repo\2023\04\11\hosts