OpenVPN is a well-known VPN client for secure remote access or virtual private networking. If you use OpenVPN and experience a slow speed over its channel, you might be getting annoyed. This issue is very common for all OpenVPN users. While the general advice you can find on the Internet is to tweak the MTU (Maximum transmission unit) value and/or MSSFIX parameters, here is another trick you should try. It can help you significantly improve the bandwith. Here's what you should try.
Open your server.conf file (see the OpenVPN installation directory in Windows and /etc/openvpn in linux) and just add these two lines:
sndbuf 0 rcvbuf 0
This will prevent OpenVPN from tweaking the buffer size between the server and the client. It will be determined by the OS. Windows users who connect to a Linux server will experience faster speeds.
Now, add the same lines to your client configuration file (*.ovpn or *.conf). If for some reason this is not possible, e.g. your client computer is not accessible, put the following additional lines in your server.conf file:
sndbuf 0 rcvbuf 0 push "sndbuf 393216" push "rcvbuf 393216"
OpenVPN over UDP
If you are running OpenVPN over UDP, you might get a better experience by setting fixed buffer values. Try these lines:
sndbuf 393216 rcvbuf 393216 push "sndbuf 393216" push "rcvbuf 393216"
The causes of the slowdown
You might be wondering why and how these tweaks work? Let's refer to the history of OpenVPN. In the year 2004, OpenVPN had a problem with different buffer sizes on different platforms. To unify the data transfer channel, developers set the fixed buffers to 64Kb. However, this caused completely strange issues with the MTU for all adapters in Windows. To fix it, developers hardcoded these lines, which work for non-Windows based servers and clients:
#ifndef WIN32 o->rcvbuf = 65536; o->sndbuf = 65536; #endif
These lines are still presented in the OpenVPN source code, so that is why we are getting the slowdown! Additionally, you can try experimenting with MTU and MSSFIX parameters, if you know what you are doing.
Try with these lines in your config:
tun-mtu 1400 mssfix 1360
In the most common case, MTU on the physical interface is 1500, so it is better to set OpenVPN TUN MTU to a value lower than the real MTU, and MSSFIX to MTU-40, as in the example above.
I hope this article was helpful for you. Share your speed results if you saw a significant improvement (via habr).
Support us
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:
My boy Chryscznaag told me about this and I checked it out. The snd\rcvbuf 0 and push 393216 made the best speed increase personally. Thanks!
i added these lines in the config of the server instead of the client and it had the same effect
push “sndbuf 393216”
push “rcvbuf 393216”
The changes did improve the download speed. But not the upload speed. Thanks. But the improvements was next to nil when the openvpn was running inside a docker container. Any idea why?
Thanx so much. Speed increased from 480K/sec to 19800K/sec.
Definately try this is your openvpn connection is slow … I am using TCP.
Thanks a lot. It works perfect.
You are welcome.
I have an openvpn box and i can not configure the server. The Windows client dosent change the buffers. THe Directive is not effecting. On my Linuxserver the push command succeeds I had about 600-700 Kbytes in UP-Load now its up to 8 Mbytes. The Uploadspeed is 100% more but in Relation to the possible Spped of 10 Mbit its 1,3 Mbyte. I will contact the Vendor of the vpn-box to change the configuration.Thank you very much.
Just wondering. I’m using OpenVPN on an android TV box (running actual android TV as the OS). Is there a way to perform these modifications on that platform? I’m trying to get it to run faster. Without the VPN going, I get between 60 and 70 down speeds. with the VPN on, it drops to around 15 down. I’m hoping this might help. Thanks!
Thanks setting the MTU and MSFIX helped a whole punch ping went from 2-3000 to 48! :D
Hi !
Thank you so much for your tips !
Using PiVPN (OpenVPN) on my Raspberry Pi3, I added these lines (using UDP) :
sndbuf 393216
rcvbuf 393216
push “sndbuf 393216”
push “rcvbuf 393216”
It increased download speed from 0.5Mb/s to 2Mb/s (on my smartphone in 4G).
And adding these :
tun-mtu 1400
mssfix 1360
It increased download speed from 9Mb/s, so 18 times faster then at the beginning.
Thanks again !
Hey..Thanks for the tweaks..but i am not able to add them.
If you can post them by screenshots it will be very helpful
Why not:
push “sndbuf 0”
push “rcvbuf 0”
?
I duplicate from 1.5mb/s to 3mb/s, good results but not the full speed of my internet connection. Without VPN i transfer data at 22mb/s :D
Thank you so much. After adding the lines:
sndbuf 393216
rcvbuf 393216
push “sndbuf 393216”
push “rcvbuf 393216”
To my server’s OpenVPN config, my speeds increased from 10 Mbps to a maximum of 30 Mbps. Then after adding the lines:
tun-mtu 1400
mssfix 1360
To my server, my speeds increased from 30 Mbps to 100 Mbps.
Sorry but i can’t find the server.config file?
Thanks a lot! It did the trick, from 50s to 2s
I was coming here to see a UNIX specific openvpn tuning when I noticed this only affected windoz users, what can I say they deserved it :-)
Fix works excellent for VPNs over long distances. Got a boost from 1Mbps to 8Mbps. Thanks for sharing it
On ubuntu 18.04 running on Microsoft Azure without network acceleration, this increased my download speed x4 and increased my upload speed x2
sndbuf 393216
rcvbuf 393216
push “sndbuf 393216”
push “rcvbuf 393216”
tun-mtu 1500