一、安装wireguard-go
Github地址:https://github.com/WireGuard/wireguard-go
编译安装
一些需要的软件yum install -y wget git make
如果是debian/ubuntu:apt install -y wget git make
1.安装golang1.16
wget https://golang.org/dl/go1.16.1.linux-amd64.tar.gz
tar xvf go1.16.1.linux-amd64.tar.gz -C /usr/local
cat <<EOF >> /etc/profile
#golang env config
export GO111MODULE=on
export GOROOT=/usr/local/go
export GOPATH=~/gopath
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
EOF
source /etc/profile
2.拉取代码并编译
git clone https://git.zx2c4.com/wireguard-go.git
git checkout 0.0.20201118
cd wireguard-go
make
mv wireguard-go /usr/local/sbin
#下载编译好的二进制文件安装
#一些需要的软件yum install -y wget
#如果是debian/ubuntu:apt install -y wget
wget https://github.com/peng4740/wireguard-go-builder/releases/download/0.0.20201118/wireguard-go-linux-amd64.tar.gz
tar zxf wireguard-go-linux-amd64.tar.gz
mv wireguard-go /usr/local/sbin
rm -f wireguard-go-linux-amd64.tar.gz
二、安装wgcf
这个是用来生成warp配置的
Github地址:https://github.com/ViRb3/wgcf
安装
wget https://github.com/ViRb3/wgcf/releases/download/v2.2.2/wgcf_2.2.2_linux_amd64 -O /usr/local/sbin/wgcf
chmod +x /usr/local/sbin/wgcf
三、用wgcf生成配置
echo|wgcf register
wgcf generate
sed -i '/0\.0\.0\.0\/0/d' wgcf-profile.conf
#sed -i '/\:\:\/0/d' wgcf-profile.conf # 如果是IPV6VPS要添加IPV4则改用这个,上一条不要执行
mkdir -p /etc/wireguard
cp -f wgcf-profile.conf /etc/wireguard/wgcf.conf
安装wireguard-tools
CentOS7:yum install -y wireguard-tools
如果提示找不到包安装失败了可能是没有epel源,先安装yum install epel-release -y
其他系统其实也是差不多的
Debian、Ubuntu:apt install wireguard
没说到系统可参考官网教程:https://www.wireguard.com/install/
四、运行测试
1.启动
wg-quick up wgcf
#如果运行完就失联了(VPS的SSH终端没反应了)。先重启VPS,检查一下配置有没有问题。
#提示没有权限解决方案
vi /etc/sysctl.conf
#修改disable_ipv6的所有变成0
#然后
/sbin/sysctl -p
当然,也不用太担心,如果你没漏掉什么步骤,一般是不会有事的。
2.测试
curl ipv6.ip.sb
如果能正常显示ip就正常
五、配置开机自启(务必要运行测试过后再配置)
systemctl enable wg-quick@wgcf
六、配置V2,增加ipv6的解析
1. "outbounds":
2. [
3. {"protocol": "freedom","tag": "direct","settings": {}},
4. {"protocol": "freedom","tag": "directv6","settings": {"domainStrategy": "UseIPv6"}},
5. {"protocol": "blackhole","tag": "blocked","settings": {}},
6. {"protocol": "freedom","tag": "twotag","streamSettings": {"network": "domainsocket","dsSettings": {"path": "/usr/local/etc/xray/ss","abstract": true}}}
7. ],
8.
9. "routing":
10. {
11. "rules":
12. [
13. {"type": "field","outboundTag": "directv6","domain": ["geosite:netflix","geosite:google"]},
14. {"type": "field","inboundTag": ["onetag"],"outboundTag": "twotag"},
15. {"type": "field","outboundTag": "blocked","ip": ["geoip:private"]},
16. {"type": "field","outboundTag": "blocked","domain": ["geosite:private","geosite:category-ads-all"]}
17. ]
18. }