Skip to content

udp2raw UDPspeeder OpenVPN原生运行在windows macOS上加速全流量

wangyu- edited this page Aug 24, 2018 · 16 revisions

原理图

(图本身分辨率很高,如果看不清楚,请单独打开图片查看)

配置OpenVPN

在VPS(linux系统)和本地安装好OpenVPN,并准备好证书和配置文件。 启动OpenVPN server端,Client先不要启动。

OpenVPN配置文件

Server端
local 0.0.0.0
port 7777
proto udp
dev tun

ca /etc/openvpn/easy-rsa/2.0/keys/ca.crt
cert /etc/openvpn/easy-rsa/2.0/keys/server.crt
key /etc/openvpn/easy-rsa/2.0/keys/server.key
dh /etc/openvpn/easy-rsa/2.0/keys/dh1024.pem

server 10.111.2.0 255.255.255.0
ifconfig 10.111.2.1 10.111.2.6

client-to-client
duplicate-cn
keepalive 10 60

max-clients 50

persist-key
persist-tun

status /etc/openvpn/openvpn-status.log

verb 3
mute 20

comp-lzo no   #this option is deprecated since openvpn2.4. For 2.4 and above, use "compress" instead
#compress

fragment 1200       ##### very important    you can turn it up a bit. but, the lower the safer
mssfix 1200         ##### very important

sndbuf 2000000      ##### important
rcvbuf 2000000      ##### important
txqueuelen 4000     ##### suggested

replay-window 2000  ##### suggested
client端
client
dev tun100
proto udp

remote 127.0.0.1 3333
resolv-retry infinite 
nobind 
persist-key 
persist-tun  

ca ./ca.crt
cert ./client.crt
key ./client.key

keepalive 3 20
verb 3
mute 20

comp-lzo no   #this option is deprecated since openvpn2.4. For 2.4 and above, use "compress" instead
#compress

fragment 1200       ##### very important    you can turn it up a bit. but, the lower the safer
mssfix 1200         ##### very important

sndbuf 2000000      ##### important
rcvbuf 2000000      ##### important

replay-window 2000  ##### suggested

route 44.55.66.77 255.255.255.255 net_gateway
redirect-gateway def1
dhcp-option DNS 8.8.8.8
block-outside-dns          ### For non-Windows user delete this line
#route 0.0.0.0 128.0.0.0
#route 128.0.0.0 128.0.0.0

在服务端添加iptables规则 开启ipforward

iptables -t nat -A POSTROUTING -s 10.111.0.0/16 ! -d 10.111.0.0/16 -j MASQUERADE
echo 1 >/proc/sys/net/ipv4/ip_forward

运行udp2raw 和udpspeeder

在vps端运行

 ./speederv2 -s -l0.0.0.0:20000 -r127.0.0.1:7777 -f10:10 --mode 0
./udp2raw -s -l0.0.0.0:20001 -r 127.0.0.1:20000  --raw-mode faketcp  -a -k passwd

在本地运行

udp2raw_mp.exe -c -r44.55.66.77:20001 -l 127.0.0.1:8855 --raw-mode easyfaketcp -k passwd  #或者添加防火墙规则后用faketcp模式
speederv2.exe -c -l0.0.0.0:3333 -r127.0.0.1:8855 -f10:10 --mode 0 --report 10
note

本地是linux系统的用户用如下命令运行udp2raw:

./udp2raw_mp -c -r44.55.66.77:20001 -l 127.0.0.1:8855 --raw-mode faketcp -k passwd -a  

完成

用openvpn client +前面准备好的配置文件,运行,不出意外即可连上server。本地所有流量tcp/udp/icmp都会被udp2raw和UDPspeeder加速。

(但是注意你本地到VPS的流量默认是不走OpenVPN+udp2raw+UDPspeeder的,如果走了OpenVPN会产生环路)