目录

解决VPS频繁Google人机验证(IP被ban)

前两天入手了RackNerd的一台VPS,选的区域是华盛顿西雅图,搭建好magic上网之后,访问Google老是跳人机验证,非常频繁,用起来特别烦人(问tg群里大哥说好像除了洛杉矶区域外基本都跳Google人机验证),都有种想换搜索引擎的冲动。但是本着要解决问题和爱折腾的态度,还是尝试解决一下吧。

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAbQAAAB0CAMAAADadTd0AAABjFBMVEX5+fkAAAD////X19dnZ2ezs7NDifIcOqnAwMD7+/v39/e8vLzExMT09PTKysr7+/rPz8/x8/cOMqdvfsGyt9k3g/L48++Zc088Oz2fuuD///gAKqVAPz2w0fC2tLGLe2iDUjhWmPTs4tJxTDr67+Coo57i4eEbOamKos9JT1fI4/o7PU2UZEt1lsKVgm6jdl5lfJDi7/uVj5u0q566zeTVvJ2KsNChsMxWQjrj2MLi9PncyrGPmK10dHQYFxdsou9MSkvUvKjOv7OYl5e1ws3++eqktMbA1OxYWFjO1+msx/IAJqQELpZ6mde8v9je4elHW64hQ6iNqNOJuPBIc7ZBVrIvSKusyvOUns9onPONpc17qvAAE6EjMEetkHKowuE6PURadJ7az8StsL5IbKBqPylmankuKyt8jKO5qZN8gI09VW1MYogVFiInHBZznsJ9RSQwP15qVGBHOTFyZFlvh7Ncd5fCon9qV07v1rluf5K0h2TMqI9/XUNIW41xioawjHZmUT5NNi2RjIp9FtZAAAANAElEQVR4nO2djXsSRxrA11mpvMAyu7lm3eKaKLIbo60VSDQhqMASItoGq3dnP641QptI4531tLa2tXde/vF7Z5ZvSNioS1if+fk8SPZjnrA/3pl3dmcm0jFB4JCO+hcQHB4hLYAIaQFESAsgbWnXzZvHBdPNtesD0kIxVRZMN3aoT9r1kGxHJMFUo9jy9V5p12wb4Kh/KcHBANgxs0facVkRzqYeUOTjfdKO+hcSeEFICyBCWgAR0gKIkBZAhLQAIqQFECEtgAhpAURICyBC2qShozlMEULahKHp04NsLlU1CQ7hTUibNPTWbD9nT92+ffuzz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g/IqQFECEtgAhpAURICyBCWgAR0gKIkBZAhLQAIqQFECHNb3z4owVCmi8AHw/K39k1D8e3xkh5LF1I8wNat0JWgy/iAmuV4Qdig6QsPhnU67w6Ic0PEqW8rM5l0mztfTbLh6/PIbVnEFHKV1bsMaTH5WxDVXN8KSloLU4F7qwiIENLhwtpfpAoXSVEb27U5VKtXk2WNUhG06loqAygx0JVqV4FWu99JA1kuaIBpNhEvmS5VGbr0lWToUYOj5srDz4GFdL8gEmDpFVdc0K15cr6Xg1DT882Yk450WyErcpqPrdulaHnAQ0waetOKOZUV50Qnhidc5yo1YBlJ5bND4zoENL8IFFqhMNWQyliwKGNYkVvLulyWimWU5kaSTb07AX+XBrrxbjK44hLW3Vku/lgNa+RNTbuZ4m8bKSLFU0fnCkhpPkBb9NkjaI0ZiOZtzM5vYTJSTmZZ4+rE6VKjI2dg5RlNdylAfAwWnIsi4VhBNbKgLUrk5bKWo3BAQdCmh+gFJaDtKXhhS9D3UmTIkqrUVvFmHKW2qtXuj0DFmlrDUxdCJNWbEvTZE0JZ3L9xQtpfoBtGp/S1JJGS3xOTDnslCPNimxdJevOwCArLi2VCcmhal+k5Zp5uZgX0iYArfM4ovUqhTrLHcNp0OuhML7HBBE3kOZA7w3WqhG+3kM0ZzewdVNBL7FEUlsvhRqDqzUIab7QXXRB6qx2T/l/fOZTJDm0bEZ3BFDnpNYJfT06zoA0MVp4EtDkqHHDXgGlT5oZtsXfZJ0AoChv/ocmAGz7Wo+0Y5ZsK+/ytxPsw1uEhmLLoeu90o6FbFkw5cSut2S1pV2/dlww5ZjHBqQJAoSQFkCEtAAipAUQIS2A/B/PxVzOQ2svXAAAAABJRU5ErkJggg==

:warning: 以下部分内容来源于网络,仅做个人备份学习使用。

解决方案

网上搜集的解决方案有以下几种:

申请免费的IPv6隧道

首先申请一个免费的IPv6隧道,这里我使用的是Tunnelbroker,免费简单好用。

申请账号的过程非常简单,输入一些虚拟的个人信息就行,直接胡编乱填就行了,或者在虚拟外国身份站点上随机一个身份信息,填好邮箱接受邮箱验证就完事了。

https://cdn.agou-ops.cn/others/image-20211202092104454.png

申请完账号之后登录,点击左边的这个Create Regular Tunnel创建一般隧道,输入你的IPv4公网IP,选择一个合适的隧道服务器节点,系统会自动选择和你区域相当的节点,所以默认就可以,然后直接点击下方的Create Tunel即可.

https://cdn.agou-ops.cn/others/image-20211202092502459.png

创建完成之后,点击隧道详情,就可以看到申请好的IPv6地址:

https://cdn.agou-ops.cn/others/image-20211202092729022.png

要使用的是上图红框中的IPv6客户端地址.

配置服务器使用IPv6隧道

Tunnelbroker的隧道详情页中点击Example Configurations示例配置,找到匹配自己VPS系统的配置片段,这里我以我的Ubuntu 20.04为例(其他发行版类似):

https://cdn.agou-ops.cn/others/image-20211202093034680.png

需要输的命令挺多的,这里我整理为脚本,一条命令傻瓜式运行即可,建议直接使用root用户运行,省事:

:question:不想看脚本?请直接跳到:smile: 运行在线的jio本

 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
#!/usr/bin/env bash 
set -euo pipefail

#
#**************************************************
# Author:         AGou-ops                        *
# E-mail:         agou-ops@foxmail.com            *
# Date:           2021-12-02                      *
# Description:                              *
# Copyright 2021 by AGou-ops.All Rights Reserved  *
#**************************************************

# ----------------
echoColor(){
  echo -e "\033[36m$1 \033[0m"
}

# 启用ipv6

cat << EOF >> /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
EOF

sysctl -p
echoColor "====== 启用ipv6 ======\n"

# !!!!!重要!!!!!
# 将下面的重定向内容替换为上面示例的配置片段内容
cat << EOF >>  /etc/network/interfaces

 auto he-ipv6
  iface he-ipv6 inet6 v4tunnel
   address xxxx:xxx:a:10d::2
   netmask 64
   endpoint 216.xx.xx.xx
   local 23.xx.x.xx
   ttl 255
   gateway 2001:xx:a:10d::1
EOF

echoColor "====== 修改网络配置文件成功 ======\n"

apt update -y 2>&1 > /dev/null
apt install ifupdown dnsutils -y 2>&1 > /dev/null

echoColor "====== 安装必要包完成,图个方便,不为啥 ======\n"

sleep 1
# 启动ipv6网络接口,如果没生效可以尝试重启网络
ifup he-ipv6
echoColor "====== 接口内容信息如下 ======\n"
ip a show dev he-ipv6

echoColor "========================\n"
# 备份原来的dns
cp -a /etc/resolv.conf{,.bak}

cat << EOF >> /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF

echoColor "====== 修改dns完成 ======\n"

# 这里用ping查看ipv6地址也可以,这里我图方便使用dig好了
google_ipv6=$(dig www.google.com AAAA | grep -E "^www" | awk '{print $5}')

echo "$google_ipv6 www.google.com" > /etc/hosts

echoColor "====== 修改hosts文件完成 ======\n"

# 默认访问时会使用IPv6线路进行访问,考虑到速度问题,建议优先使用IPv4
sed -i 's@#precedence ::ffff:0:0/96  100@precedence ::ffff:0:0/96  100@g' /etc/gai.conf

echoColor "====== 配置优先IPv4完成 ======\n"

echoColor "\n\nDone."

使用root用户运行以上jio本:

1
2
chmod +x install_ipv6_tunnel.sh
./install_ipv6_tunnel.sh			# 等待安装完成即可

:smile: 运行在线的jio本

直接在线运行上面的脚本,不用手动复制然后执行了,一条命令完事:

1
wget -P /root -N --no-check-certificate "https://gist.githubusercontent.com/AGou-ops/d0c65269da6c77e49a410c6dbe9ce244/raw/e81ed2bcaea9aef80eeda799adbba2bfb63b2f67/install_ipv6_tunnel.sh" && chmod +x /root/install_ipv6_tunnel.sh && /root/install_ipv6_tunnel.sh

检查VPS的IPv6地址

检查VPS的IPv6地址是否生效,以及VPS的网络是否IPv4优先:

1
2
3
4
5
6
7
# 查询本机外网IPv6地址
curl 6.ipw.cn
# 备用查询地址
curl ipv6.ip.sb

# 测试网络是IPv4还是IPv6访问优先(访问IPv4/IPv6双栈站点,如果返回IPv6地址,则IPv6访问优先)
curl test.ipw.cn

也可以浏览器直接访问https://ipw.cn/进行查看.

Done.

参考链接