Google Host Patch自动获取脚本

2011年8月11日 | 分类: 翻墙相关 | 标签: , ,

Google最近发布了Google Plus,但是几乎是刚刚一发布就无法访问,同时面对着GMail,Google搜索越来越频繁的连接阻断问题,我们急需要一个方案来更方便的访问Google服务。
如果在校园网中,IPv6无疑是一个良好的解决方案,本博这篇文章给出了相关方法,在Google Code上也有一个Project专门维护Google IPv6的Host列表。

但是在没有IPv6环境的情况,这个自动脚本就有了意义。本脚本最初来自Google+ 上的Felix Hsu,他已发布正式版,但是我还是个人更喜欢这个version 3一些~ XD

Windows Vista/7用户在开启UAC的情况下需要“右键->以管理员的身份运行”

点击此下载该脚本

 

hostsp_v3.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
@echo off
REM 欢迎圈我,在顶栏的"查找人员"处输入Felix Hsu即可
REM Mod by logicmd
REM 准备工作,先清一下DNS缓存,再备份hosts
ipconfig /flushdns
cls
REM 测试时有的朋友会不耐烦的点掉,咱提示一下:
echo Google+ hosts自动修改脚本
echo 请稍等一下,正在通过网络获取可用IP
REM 然后ping www.google.cn和www.google.com以获取最新的IP,赋值%CNIP%和%COMIP%
REM ping ditu.google.cn获取最新的IP,赋值%MAPIP%
for /f "tokens=2 delims=[]" %%i in ('ping www.g.cn') do set CNIP=%%i
for /f "tokens=2 delims=[]" %%i in ('ping www.l.google.com') do set COMIP=%%i
for /f "tokens=2 delims=[]" %%i in ('ping ditu.google.cn') do set MAPIP=%%i
REM 找到之前改过的行,删掉,很stupid的方法...
type %windir%\System32\drivers\etc\hosts|find "#THISISNOTE" /i /v|find "#Google Plus" /i /v|findstr "." >>%windir%\System32\drivers\etc\hosts2
ren %windir%\System32\drivers\etc\hosts hosts3
ren %windir%\System32\drivers\etc\hosts2 hosts
del hosts3 /s /q
REM 为了美观和避免直接在文件末尾添加的惨剧,咱空一行
echo.  >>%windir%\System32\drivers\etc\hosts
echo #Google Plus >>%windir%\System32\drivers\etc\hosts
REM 把获取到的%CNIP%和%COMIP%给写进去,为了方便以后可以删除,加了一个#THISISNOTE 的注释,我实在是想不出怎么做了,望见谅
echo %CNIP% plus.google.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% talkgadget.google.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %COMIP% picasaweb.google.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %COMIP% lh1.ggpht.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %COMIP% lh2.ggpht.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %COMIP% lh3.ggpht.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %COMIP% lh4.ggpht.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %COMIP% lh5.ggpht.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %COMIP% lh6.ggpht.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% lh6.googleusercontent.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% lh5.googleusercontent.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% lh4.googleusercontent.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% lh3.googleusercontent.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% lh2.googleusercontent.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% lh1.googleusercontent.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% plus.google.com.hk  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% plusone.google.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% s2.googleusercontent.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% s1.googleusercontent.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% images1-focus-opensocial.googleusercontent.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% images2-focus-opensocial.googleusercontent.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% images3-focus-opensocial.googleusercontent.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% images4-focus-opensocial.googleusercontent.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% images5-focus-opensocial.googleusercontent.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% images6-focus-opensocial.googleusercontent.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% images-pos-opensocial.googleusercontent.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% maps-api-ssl.google.com #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% www.google.com.hk  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% www.google.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% webcache.googleusercontent.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% mail.google.com #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% www.googlelabs.com #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% docs.google.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% plus.google.com #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% profiles.google.com #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% services.google.com #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% clients4.google.com #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% clients2.google.com #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% chrome.google.com #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %CNIP% tools.google.com #THISISNOTE >>%windir%\System32\drivers\etc\hosts
REM 把获取到的%MAPIP%
echo %MAPIP% maps.google.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts
echo %MAPIP% ditu.google.com  #THISISNOTE >>%windir%\System32\drivers\etc\hosts 
REM ok,搞定
echo 您的hosts编辑完成.
REM 按任意键继续的功能千万别有,否则别人问你按任意键是神马意思的话...

分享一个现成的Hosts给伸手党们~ http://goo.gl/Tx7H5

FAQ[1]

  • 这些IP是否可靠?

这些IP都来自于GoogleCN在BJ的数据中心,包括大约30个C段IP(203.208.32.0 – 203.208.63.255)

  • 这些IP都在国内理论上将是否能够一直可用?

不能保证未来的可用性。

  • 用这些Host是否意味着Google用户的Mail/Plus/Picasa存在BJ的数据中心的呢?还是采用的反向代理或者隧道一类的技术?

只是反向代理,谷歌分布式系统中的 Web server 部分,参见 [2]。

 

原文http://logicmd.net/2011/07/automatically-get-google-host-patch-script/

  1. 匿名
    2011年8月12日22:33

    好像不行了 咋搞的

    • iGFW
      2011年8月13日08:19

      呵呵呵,不是我搞的

  2. shar
    2011年8月12日22:14

    我这里google.com.*全上不去了,出来的是联通的一个“页面错误 ”的劫持页面。。。草!!!老子自从上网就基本不用baidu,这可叫我咋活呀!!!尼玛。。

    • iGFW
      2011年8月12日22:20

      呵呵,bing吧。
      要不在hosts文件里添加
      203.208.39.22 http://www.google.com.hk
      203.208.39.22 http://www.google.com
      两行试试

      • mouse
        2011年8月12日22:21

        你用just-ping.com试试 那里面好多 就是看不了视频

      • mouse
        2011年8月12日22:22

        有些速度相当快 就是看了视频 你的可以看不

      • mouse
        2011年8月12日22:25

        谷歌还可以用 就是”你脱不”不能用来 尤其是不能看视频

        • iGFW
          2011年8月13日08:19

          是呀,不知道原因。

    • mouse
      2011年8月12日22:24

      改了ip后 有时候被劫持到www.google.com

  3. mouse
    2011年8月12日22:09

    ZF真他妈垃圾,里面由于有几个所谓的瑕疵就全盘否定.

  4. mouse
    2011年8月12日22:07

    你那里可以看不 我这里还是不行 74.125.*.*实力几个好像都不行 看不了视频

  5. mouse
    2011年8月12日17:44

    修改了里面与youtube有关的所有ip,换成的这个www.youtube.com的新ip(我这里可以ping通,速度比较快)后,还是不能看视频,怎么回事呀

    • iGFW
      2011年8月12日21:06

      不清楚,一会看看。

  6. 匿名
    2011年8月12日17:40

    对此人悬赏50万 人码头

  7. 匿名
    2011年8月11日22:10

    IGFW都被和谐了,俺在深圳都上不了,翻墙过来的。前几天都能上的,呵呵

    • iGFW
      2011年8月11日22:38

      igfw.net一直都是被和谐的,你以前不翻墙能上只是个意外

  8. mouse
    2011年8月11日20:43

    昨天开始就被遭万人唾沫的方给封了

  9. mouse
    2011年8月11日18:22

    “分享一个现成的Hosts给伸手党们” 呵呵 打环境是这样 没得法