Community discussions

MikroTik App
 
jti
just joined
Topic Author
Posts: 3
Joined: Thu Jan 28, 2021 8:45 pm

L2TP IPsec keepalive ping

Thu Jan 28, 2021 9:26 pm

He everyone,
I need help please.

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.

Can someone send me a script please?

Thank you in advance for your response
 
sin3vil
newbie
Posts: 34
Joined: Sat May 26, 2018 10:05 pm

Re: L2TP IPsec keepalive ping

Fri Jan 29, 2021 8:00 pm

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.
/ip route add dst-address=8.8.8.8/32 gateway=vpn routing-mark=vpn-keepalive
/system scheduler add interval=10m on-event="ping count=4 address=8.8.8.8 routing-table=vpn-keepalive" 
 
jti
just joined
Topic Author
Posts: 3
Joined: Thu Jan 28, 2021 8:45 pm

Re: L2TP IPsec keepalive ping

Sat Jan 30, 2021 3:27 pm

Thank you for your quick response.
good idea, should work, pings go out

the couple of pings are not interested in traffic, monthly traffic is about 150gb in both directions

Who is online

Users browsing this forum: Ahrefs [Bot] and 19 guests