+-
如何访问Google: 谷歌google最近已无法访问

新建 批处理脚本sethosts.bat:

英文版本:

@echo off
ping www.google.cn -n 1| find "Reply from">ip.txt

for /f "tokens=3 delims= " %%i in (ip.txt) do set googleip=%%i

echo %googleip%

findstr /e /v /r /c:"google.com" "C:\Windows\System32\drivers\etc\hosts">>hosts

echo %googleip:~0,-1% encrypted.google.com>>hosts

echo %googleip:~0,-1% docs.google.com>>hosts

echo %googleip:~0,-1% code.google.com>>hosts

echo %googleip:~0,-1% google.com>>hosts

copy hosts "C:\Windows\System32\drivers\etc\hosts" /y

del hosts /f  /q


中文版本:


@echo off
ping www.google.cn -n 1| find "来自">ip.txt

for /f "tokens=2-15 delims= " %%i in (ip.txt) do set googleip=%%i

echo %googleip%

findstr /e /v /r /c:"google.com" "C:\Windows\System32\drivers\etc\hosts">>hosts

echo %googleip% encrypted.google.com>>hosts

echo %googleip% docs.google.com>>hosts
echo %googleip% code.google.com>>hosts

echo %googleip% google.com>>hosts

copy hosts "C:\Windows\System32\drivers\etc\hosts" /y

del hosts /f  /q


保存执行即可!

ps:怎么知道自己的cmd是中文版还是英文版:例: 

中文版ping 

来自 203.208.46.148 的回复: 字节=32 时间=38ms TTL=55

 英文版ping 

Reply from 203.208.46.148: bytes=32 time=38ms TTL=55

方法二:windows用户找到C:\windows\system32\drivers\etc下的hosts文件,Linux用户打开/etc/hosts文件。

#在文件末端加上:
203.208.46.146      www.google.com
203.208.46.147      www.google.com.hk
203.208.46.132      clients1.google.com
203.208.46.149      mail.google.com
203.208.46.161      chatenabled.mail.google.com
203.208.46.161      mail-attachment.googleusercontent.com