I'm running a simple vpn server with these softwares:
- OpenVPN
- Shadowsocks
- MTProto Proxy
My server config is:
- Ubuntu 18.04 x64
- 512Ram, 1vCPU
- UFW firewall
- Netdata monitoring
- Nginx
It's been only few days since I started running the server. Problem is Netdata keeps sending me these 3 type of errors every few hours.
- "server needs attention, ipv4.udperrors (udp), 1m ipv4 udp receive buffer errors = 12 errors"
- "server needs attention, net_drops.tun0 (tun0), outbound packets dropped = 34 packets"
- "server needs attention, net_packets.tun0 (tun0), outbound packets dropped ratio = 0.33%"
I thought it's not that of a big deal so I ignored them.
I'm not sure if this is a firewall issue, a system bottleneck, or one of the 3 mentioned vpn softwares are not performing well.
I looked into almost every log file in /var/log
but I couldn't find any error or problem before server went unreachable. I'm not sure if the server froze, or crashed. cause there is no log after a certain point. not until we did force a reboot.
I found out the problem. It was openvpn related. I looked at
/var/log/syslog
and apparently openvpn had an issue doing TLS handshake with the client. And it kept logging these errors:The reason was the
reneg-sec
parameter which had the default values of 3600. Here is a quote from openvpn's official docs:This parameter makes sure the client has to renegotiate their key every hour.
So if you left the openvpn on (client side) for a long time, and if for whatever reason one of the handshakes fails It would cause an endless supply of failed negotiations. I guess that caused the dropped packets and stuff.
Not to mention the "tun0" interface was made by openvpn in the first place, which I didn't know.
Anyway the solution is to change the
reneg-sec
to either a higher value, or just set it to zero and disable it. I decided to just go with the disable option and putreneg-sec 0
inserver.conf
and client.opvn
profiles.Also if you happen to use UFW, you have to edit
/etc/default/ufw
and changeDEFAULT_FORWARD_POLICY
to accept.If you still keep getting udp errors you probably also need to tweak your networking settings.