WARP+在Linux上双栈全局路由
,归类在笔记中,共有 0 条评论

WARP+在Linux上双栈全局路由

,归类在笔记中,共有 0 条评论

WARP+确实挺快的。

安装wgcf,注册,测试

自行谷歌

源进源出

修改/etc/iproute2/rt_tables,添加一张路由表。

#
# reserved values
#
255     local
254     main
253     default
252     network
0       unspec
#
# local
#
#1      inr.ruhep

修改网卡查询的路由表

ip rule add from X.X.X.X(网卡的地址) lookup network

添加缺省到路由表

ip route add table network default dev DEVICE_NAME

删除原有缺省

ip route del default

添加Endpoint路由

ip route add 162.159.192.1 via GATEWAY_ADDR dev DEVICE_NAME

禁止wireguard自动修改路由表。修改wgcf配置文件,在[Interface]下添加

Table = off

启动wgcf并添加缺省

wg-quick up wgcf
ip route add default dev wgcf
ip -6 route add default dev wgcf

完工

脚本

给出一个自动添加路由的脚本
wgcf配置文件:

[Interface]
PrivateKey = aN9H******************mpwVc=
Address = 172.16.0.2/32
Address = fd01:5ca1:ab1e:81b3:9289:fa79:8079:4b9a/128
MTU = 1280
Table = off
PostUp = /usr/bin/wgcf/up
PostDown = /usr/bin/wgcf/down
[Peer]
PublicKey = bmXOC+**************wPfgyo=
AllowedIPs = 0.0.0.0/0
AllowedIPs = ::/0
Endpoint = 162.159.192.1:2408

/usr/bin/wgcf/up

#!/bin/bash

ip rule add from X.X.X.X/X(网卡所在的网段) lookup network 
ip route add table network default via GATEWAY_ADDR dev DEVICE_NAME
ip route del default via GATEWAY_ADDR dev DEVICE_NAME
ip route add 162.159.192.1 dev DEVICE_NAME via GATEWAY_NAME
ip route add default dev wgcf
ip -6 route add default dev wgcf

/usr/bin/wgcf/down

#!/bin/bash

ip route add default via GATEWAY_ADDR dev DEVICE_NAME
ip route del table network default via GATEWAY_ADDR dev DEVICE_NAME
ip route del 162.159.192.1 dev eth0 via GATEWAY_ADDR
ip rule del from X.X.X.X/X(网卡所在的网段) lookup network 

测速

speedtest

留言
0:00