使用 CloudFlare WARP 给 VPS 添加 IPv6 网络
此文章为转载, 原文章地址: 酱儿
注册WARP
#弄个文件夹方便管理相关文件
mkdir wgcf
cd wgcf
#下载对应程序
wget -O wgcf https://github.com/ViRb3/wgcf/releases/download/v2.2.5/wgcf_2.2.5_linux_amd64
#添加执行权限
chmod +x wgcf
#注册WARP账户
./wgcf register
#生成WireGuard配置文件
./wgcf generate
修改生成出来的配置文件 vim wgcf-profile.conf
在AllowedIPs = 0.0.0.0/0
之前添加#
,取消接管IPV4,只接管IPV6.最终配置类似如下这样:
[Interface]
PrivateKey = IFpvumD5fZBUhBURe2ceJkNFB++gutmjtbln0Harq3Q=
Address = 172.16.0.2/32
Address = xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/128
DNS = 1.1.1.1
MTU = 1280
[Peer]
PublicKey = bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=
#AllowedIPs = 0.0.0.0/0
AllowedIPs = ::/0
Endpoint = engage.cloudflareclient.com:2408
安装WireGuard
先安装linux-headers
apt update
apt install linux-headers-$(uname -r) -y
apt install curl sudo lsb-release -y
然后安装网络工具箱
sudo apt install net-tools iproute2 openresolv dnsutils -y
然后安装wireguard
apt update
apt install wireguard-dkms wireguard-tools resolvconf -y
额外操作
每个人的vps配置文件中默认的 DNS 都不一样,由于它将替换掉系统中的 DNS 设置 (vi /etc/resolv.conf),同时为了防止单 DNS 服务器故障导致无法解析,建议使用不同组织提供的公共 DNS 服务器组合。以下配置供参考,小伙伴们请根据实际情况来填写。
DNS = 8.8.8.8
DNS = 8.8.4.4
DNS = 1.1.1.1
启用 WireGuard 网络接口
将 WireGuard 配置文件复制到 /etc/wireguard/ 并命名为 wgcf.conf。
sudo cp wgcf-profile.conf /etc/wireguard/wgcf.conf
开启网络接口(命令中的 wgcf 对应的是配置文件 wgcf.conf 的文件名前缀)。
sudo wg-quick up wgcf
执行ip a命令,此时能看到名为wgcf的网络接口 显示类似如下:
wgcf: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1280 qdisc noqueue state UNKNOWN group default qlen 1000
link/none
inet 172.16.0.2/32 scope global wgcf
valid_lft forever preferred_lft forever
inet6 fdxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/128 scope global
valid_lft forever preferred_lft forever
执行以下命令检查是否连通。同时也能看到正在使用的是 CloudFlare 的网络。
curl -6 ip.p3terx.com
测试完成后关闭相关接口,因为这样配置只是临时性的。
sudo wg-quick down wgcf
正式启用 WireGuard 网络接口
# 启用守护进程
sudo systemctl start wg-quick@wgcf
# 设置开机启动
sudo systemctl enable wg-quick@wgcf
ipv6测速
curl -fsSL git.io/speedtest-cli.sh | sudo bash
speedtest