I have a problem with a vpn connection (l2tp/ipsec) to a l2tp/ipsec server (CyberGhost VPN).
As long as traffic flows within half an hour, the connection is not disconnected.
If there is no traffic, the connection is disconnected and re-established exactly every half hour.
it´s strange.
Keepalive timeout in the interface (PPP L2TP Client) it does not work. i have testet.
With PPTP-Protocol it work and it gives no disconnections.
My idea:
A script that sends a ping every 20 or 25 minutes to an ip on the internet via the L2TP / IPsec interface.
But only if the interface is enabled.
Unfortunately, I don’t have much experience script language.
Below two commands sort of fit your requirement.
The first one sets up a static route via the vpn (assuming it’s named “vpn”) with a routing mark, so it will only apply to traffic marked for that route.
The second command sets up a scheduler that fires every 10 minutes and runs a ping with 4 packets towards google dns.
It doesn’t only run when the vpn is up, but assuming you’re not on an extremely traffic limited connection, the 24 packets x 64 bytes, per hour, it doesn’t really matter.