Skip to content

win10系统UDPspeeder OpenVPN的完整设置

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

虚拟机的网络设置

image

open2

确保你的桥接设置跟我图里的一样。

命令和配置文件

OpenVPN client运行在win10,UDPspeeder client运行在虚拟机;OpenVPN server和UDPspeeder server运行在Vultr日本的VPS,debian系统。

OpenVPN client(win10):

client
dev tun100       #也可只写dev tun       也可用tap
proto udp            #需要和server一致

remote 192.168.100.59 1234
resolv-retry infinite  #无限次尝试连接服务器
nobind  #???
persist-key  #断线重连不重新读取key
persist-tun  #断线重连不up/down close/reopen tun接口

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

redirect-gateway def1  #让openvpn来修改路由表
dhcp-option DNS 8.8.8.8

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

cipher none #不和server设成一样会报warrning
auth none

fragment 1200
mssfix 1200

sndbuf 4000000
rcvbuf 4000000
#txqueuelen 4000
mute-replay-warnings

OpenVPN server(VPS):

local 0.0.0.0

port 7777 #端口,需要与客户端配置保持一致
proto udp #使用协议,需要与客户端配置保持一致
dev tun100 #也可以选择tap模式


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.222.2.0 255.255.255.0 #给客户的分配的IP段,注意不要与客户端网段冲突!
ifconfig 10.222.2.1 10.222.2.6

client-to-client #client 间可见
duplicate-cn #允许同一个证书建立多个连接
keepalive 10 60 #每10秒一ping 连续60秒没消息就认为连接失败

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

cipher none #传输数据不加密,但不关闭验证
auth none
max-clients 50

persist-key
persist-tun

status /etc/openvpn/openvpn-status.log
#log-append /etc/openvpn/openvpn.log# 添加这行以后所有输出都写到openvpn.log

verb 3
mute 20  #mute重复消息

mssfix 1200
fragment 1200

sndbuf 4000000
rcvbuf 4000000
txqueuelen 4000

VPS里的UDPspeeder命令:

./speederv2_amd64 -s -l0.0.0.0:8855 -r127.0.0.1:7777  --mode 0  --report 20

虚拟机里的UDPspeeder命令:

./speederv2_x86  -c -r44.55.66.77:8855 -l0.0.0.0:1234  --mode 0  --report 20

VPS里全部的网络设置如下:

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

虚拟机上没有做过任何网络设置。windows上除了后面会说到的dns设置,没有任何其他网络设置。

以上贴出来的就是所有配置和命令了,再也没有其他的了。

经过以上的设置,直接就好使了,打开ip138显示的是VPS的IP。

dns问题

唯一遇到的问题是,貌似win 10上的dns设置有点BUG,win 10总是用我无线网卡上的DNS查域名,获得到了被污染的地址,打不开google系的网站;我把无线网卡的DNS改成1.1.1.1(一个无效的值),强制windows不用无线网卡查DNS,然后就完全正常了。

貌似在OpenVPN client的conf里加上block-outside-dns也可以解决这个问题(未测试)。

其它可能会遇到的问题

ISSUE中多次有人遇到了openvpn连接以后,ping不通虚拟机的问题。疑似是openvpn push "redirect-gateway def1"选项的BUG(不过我自己没有遇到过,有可能这个BUG跟openvpn的版本有关)。问题细节可以看 这里

去掉openvpn push "redirect-gateway def1",手动添加路由规则可以解决。