Weird behavior of L2TP / IPSEC in ROS7 hAP AX3 / Arm64

Hello,

one of my older 6.x routers died, so I replaced it with a new hAP ax3 (Arm64), last stable ROS 7.15.2 and I have issues with L2TP/ipsec vpn with shared secret (working for years until now). I know Mikrotik has done some of their beloved functionality-breaking “upgrades” around 6.44, moving a lot of ipsec settings to different locations, but apart from that, I was able to make it work, but it acts really weird. I know the ipsec usage/shared secret had to be enabled either in L2TP server settings, or set in ip/ipsec, not both. First one does not work, the second one does, but it seems Mikrotik is tampering with my settings, deleting or hiding my settings (I suspect the tempate policy generation?), changing peer to unknown, it freezes during just “ip/ipsec/peer print” and most of all, stops working until disabled/enabled.

1, First of all - sometimes Mikrotik kicks out users and when it does, users are not able to reconnect until L2TP interface is disabled/enabled on ROS.

 07-15 14:30:54 ipsec,error no auth method defined for peer
 07-15 14:30:54 ipsec,error 37.x.x.x failed to get valid proposal.
 07-15 14:30:54 ipsec,error 37.x.x.x failed to pre-process ph1 packet (side: 1, status 1).
 07-15 14:30:54 ipsec,error 37.x.x.x phase1 negotiation failed.
 07-15 14:30:58 ipsec,info respond new phase 1 (Identity Protection): 84.y.y.y[500]<=>37.x.x.x[30554]
 07-15 14:30:58 ipsec,error no auth method defined for peer
 07-15 14:30:58 ipsec,error 37.x.x.x failed to get valid proposal.
 07-15 14:30:58 ipsec,error 37.x.x.x failed to pre-process ph1 packet (side: 1, status 1).
 07-15 14:30:58 ipsec,error 37.x.x.x phase1 negotiation failed.
 07-15 14:30:59 ipsec,info respond new phase 1 (Identity Protection): 84.y.y.y[500]<=>37.x.x.x[30554]
 07-15 14:30:59 ipsec,error no auth method defined for peer
 07-15 14:30:59 ipsec,error 37.x.x.x failed to get valid proposal.
 07-15 14:30:59 ipsec,error 37.x.x.x failed to pre-process ph1 packet (side: 1, status 1).
 07-15 14:30:59 ipsec,error 37.x.x.x phase1 negotiation failed.
 07-15 14:31:02 system,info L2TP Server settings changed by tcp-msg(winbox): (/interface l2tp-server server set accept-proto-version=l2tpv2 allow-fast-path=no authentication=mschap2 caller-id-type=ip-address default-profile=vpn enabled=no keepalive-timeout=30 l2tpv3-circuit-id="" l2tpv3-cookie-length=0 l2tpv3-digest-hash=md5 max-mru=1450 max-mtu=1450 max-sessions=unlimited mrru=disabled one-session-per-host=no use-ipsec=yes)
 07-15 14:31:07 system,info L2TP Server settings changed by tcp-msg(winbox): (/interface l2tp-server server set accept-proto-version=l2tpv2 allow-fast-path=no authentication=mschap2 caller-id-type=ip-address default-profile=vpn enabled=yes keepalive-timeout=30 l2tpv3-circuit-id="" l2tpv3-cookie-length=0 l2tpv3-digest-hash=md5 max-mru=1450 max-mtu=1450 max-sessions=unlimited mrru=disabled one-session-per-host=no use-ipsec=yes)
 07-15 14:31:11 ipsec,info respond new phase 1 (Identity Protection): 84.y.y.y[500]<=>37.x.x.x[30554]
 07-15 14:31:11 ipsec,info ISAKMP-SA established 84.y.y.y[4500]-37.x.x.x[30555] spi:xxxxx
 07-15 14:31:13 l2tp,info first L2TP UDP packet received from 37.x.x.x
 07-15 14:31:13 l2tp,ppp,info,account xxxvpnxxx logged in, 192.z.z.z from 37.x.x.x
 07-15 14:31:13 l2tp,ppp,info <l2tp-xxxxx>: authenticated
 07-15 14:31:13 l2tp,ppp,info <l2tp-xxxxx>: connected

as you can see, users cannot connect with “no auth method defined for peer”, “failed to get valid proposal” etc. When I disable L2TP server at 14:31:02 and instantly enable it back at 14:31:07, users magically connect. Changing keep-alive-timeout from 30 to 300 helps a lot, I changed it to 3000 now, but wtf is happening here? It creates some policies/rules when being enabled or what? I suspected the “template” setting in ip/ipsec/policy, but it seems it does not work without it. The setup seems correct since users can connect/disconnect/reconnect, but if mikrotik kicks them out, no one connects until L2TP Server is disabled/enabled again.


2, weird behavior - see pics. If I create a peer, mikrotik is hiding it but it still exists, I tried to create peer1 - peer3, none was shown in ip/ipsec/peer, but mikrotik refused to create a peer with this name, complaining “Name can’t repeat”.
peer does not exist.png
Similar to this - while having a peer l2tp-peer as you can see, mikrotik complains “l2tp-peer - object doesn’t exist” or “peer does not exist” - see attached images from winbox.
object does not exist.png
hidden peer.png

3, this is super weird - I can’t even print peers using ip/ipsec/peer print, it freezes for ~10 mins and then throws this error
peer print.png
4, it shows some strange script error timeout - probably some system script related to ipsec, since there are no user scripts running in this router. There are things happening in the background (or not happening but should happen)
script error.png




config - L2tp & ipsec related parts:

/ip ipsec profile
set [ find default=yes ] dh-group=modp1024 enc-algorithm=3des
add dh-group=modp2048,modp1536,modp1024 enc-algorithm=
aes-256,aes-192,aes-128,3des name=profile_1
/ip ipsec proposal
set [ find default=yes ] auth-algorithms=sha256,sha1 enc-algorithms=
aes-256-cbc,aes-192-cbc,aes-128-cbc,3des
add auth-algorithms=sha512,sha256,sha1,md5 enc-algorithms=
aes-256-cbc,aes-192-cbc,aes-128-cbc,3des,blowfish,twofish,des name=
proposal1 pfs-group=none


/ppp profile
add dns-server=local_ip local-address=local_ip name=vpn-l2tp
only-one=no remote-address=l2tp-pool use-encryption=required use-ipv6=
no

/interface l2tp-server server
set authentication=mschap2 default-profile=vpn-l2tp enabled=yes
ipsec-secret=ipsec_secret keepalive-timeout=3000 use-ipsec=yes

/ip ipsec policy
set 0 dst-address=local_subnet src-address=0.0.0.0/0
add disabled=yes peer=*4
add template=yes

How did you configure your new ax3, from an /export of the old device, or from a .backup?

I’m not entirely sure since I tried a lot of things, because the original unit died. But I think the latest backup I found was .backup. And since it tampered with and renamed my ethernet interfaces (and I am almost sure I did not have this on the original unit) - ether1 had default-name ether5 etc., so yes, it was probably the .backup file, although I had to change almost everything after the restore to make it work

Best bet is to use net reinstall with a clean version of 7.1X of your choice. Following the bouncing bugs not sure what is the best version to use currently 7.13?

Before netinstalling as suggested by @llamajaja, do an export of the configuration into a file rather than saving a backup. The difference is not only that export creates a script whereas system backup save stores a binary file, but also the information contents. It is only safe to system backup restore a configuration from the backup file on the same model of router as the one where the backup has been saved; restoration on any other model causes unpredictable issues like the one you have encountered.

Recreating configuration from the exported script also has its drawbacks (the safest way is to copy-paste the configuration block by block from the export text file to the command line and fix eventual errors), but it doesn’t break things under the hood.

The export does not contain user accounts and certificates. Certificates can be exported using certificate export-certificate command, and you must provide a passphrase to export the private key along with the certificate - without the passphrase, the certificate is exported without the private key, and without the private key, any own certificate becomes useless. User accounts cannot be exported by any means.

1 Like

I forgot to reply, but you guys have been probably right, new setup from scratch had no issues.

Although this is pretty unfortunate for me, since it moves Mikrotik to the category of crap without full backup/restore ability for disaster recovery, damn :-/