WARP添加ipv6

2021-04-03 13:37:43 -0400
部分便宜/免费 VPS 只提供 IPv6 地址,搭建魔法工具后是无法访问大多数只提供 IPv4 地址的网站(例如 Github),我们可以通过 Cloudflare Warp 提供的 Wireguard 隧道来变相打通 v6 to v4。也可以为 IPv4 Only VPS 加上 IPv6 支持,目前(截至发布日)Warp 提供的 IPv6 地址能解锁 Netflix。

2

搭建方式
本方式基于 Debian 10 Buster 并且使用 root 用户。

0 准备工作
安装必要软件

apt update && apt install wget vim lsb-release -y
1 获取 Warp 配置文件
通过 wgcf 工具获取 Warp 配置文件:

wget -O wgcf https://github.com/ViRb3/wgcf/releases/download/v2.2.2/wgcf_2.2.2_linux_amd64 && chmod +x wgcf
注册账号

./wgcf register
获取配置文件

./wgcf generate
(如果提示 429 Too many requests 错误,多 gen 几次)

即会在在当前目录生成 wgcf-profile.conf 文件,根据 VPS 实际情况编辑此文件

vim wgcf-profile.conf
按 i 开始编辑文件

IPV6 Only VPS

删除 AllowedIPs = ::/0 行,仅保留 AllowedIPs = 0.0.0.0/0

最后一行 Endpoint 改为 [2606:4700:d0::a29f:c001]:2408

IPV4 Only VPS

删除 AllowedIPs = 0.0.0.0/0 行,仅保留 AllowedIPs = ::/0

最后一行 Endpoint 改为 162.159.192.1:2408

3

按 Esc 键,并输入 :wq 保存文件,将此文件复制到 Wireguard 配置文件夹

mkdir /etc/wireguard && cp wgcf-profile.conf /etc/wireguard/wgcf.conf
2 安装 Wireguard
添加 backports 源

echo "deb http://ftp.debian.org/debian buster-backports main" >> /etc/apt/sources.list
安装最新内核

apt install -t $(lsb_release -sc)-backports linux-image-$(dpkg --print-architecture) linux-headers-$(dpkg --print-architecture) --install-recommends -y
安装 Wireguard

apt install wireguard openresolv -y
将 Wireguard 设置成开机启动

systemctl enable wg-quick@wgcf
重启 VPS

reboot
重启后可通过命令 wg 检查启动是否成功。

WG连接后是内核层级的软件,会建立自己的虚拟网卡,且WARP客户端均为内网NAT地址,当双栈流量均被WG接管后我们就无法再从原有的IP连接到服务器了。因此在IPv4与IPv6之间我们必须做一个取舍,以防这样的情况发生。
修改配置文件就两种情况:

①上文图中11行Endpoint修改为162.159.192.1:2408,删除掉第9行接管本地IPv4路由的配置
②上文图中11行Endpoint修改为[2606:4700:d0::a29f:c001]:2408,删除掉第10行接管本地IPv6路由的配置

接下来就是安装wireguard客户端。

centos7可以使用以下命令安装:

$ sudo yum install epel-release elrepo-release
$ sudo yum install yum-plugin-elrepo
$ sudo yum install kmod-wireguard wireguard-tools
更多命令可以参考官方网站:https://www.wireguard.com/install/

安装好以后记得重启下VPS。

把刚刚下载好的配置文件wgcf-profile.conf上传至/etc/wireguard,然后修改下配置文件,其中DNS建议同时添加上IPV4与IPV6的DNS,这里使用的Cloudflare的DNS。

For IPv4: 1.1.1.1 and 1.0.0.1
For IPv6: 2606:4700:4700::1111 and 2606:4700:4700::1001
同时记得如果需要cf warp的IPV6就删掉 AllowedIPs = 0.0.0.0/0,如果需要cf warp的ipv4就删掉 AllowedIPs = ::/0。

记住不要两个同时启用,不然会导致你vps原本的ip地址无法连接上去。博主就上了这个当。

最后保存配置文件,修改文件名为wgcf.conf 然后继续:

#加载内核模块
modprobe wireguard
#检查WG模块加载是否正常
lsmod | grep wireguard
最后开关隧道的命令为:

#开启隧道
sudo wg-quick up wgcf
#关闭隧道
sudo wg-quick down wgcf
如果VPS出口没有走ipv6的话,需要这样做

编辑 /etc/gai.conf 文件(没有的话就新建),修改为以下内容:

label ::1/128 0
label ::/0 1
label fd01::/16 1
label 2002::/16 2
label ::/96 3
label ::ffff:0:0/96 4
label fec0::/10 5
label fc00::/7 6
label 2001:0::/32 7
precedence ::1/128 50
precedence ::/0 40
precedence fd01::/16 40
precedence 2002::/16 30
precedence ::/96 20
precedence ::ffff:0:0/96 10
对了附上成功解锁NF的截图
«Newer      Older»
Comment:
Name:

Back to home

Subscribe | Register | Login | N