Possible Issue with random-source-port in MikroTik L2TP

I may have found a possible issue related to the random-source-port setting in MikroTik L2TP clients.

Test scenario:

  • About 200 l2tp-client instances.
  • These clients are constantly being reconnected (disconnect/reconnect loop).
  • /ip/service shows the L2TP service with its assigned ports.

Observation:

  • When random-source-port is enabled, the L2TP service port usage keeps increasing over time.
  • It seems that old/invalid port bindings are not released after the client disconnects.
  • Eventually, this leads to a large number of “stale” ports being listed as in use, even though those sessions are no longer active.

Possible impact:

  • System resource usage may increase over time.
  • In extreme cases, it could cause L2TP connection issues or prevent new connections due to port exhaustion.

Questions:

  • Is this expected behavior for L2TP with random-source-port enabled?
  • Should the unused ports be automatically released after the client disconnects?

If possible, it would be great to have:

  • L2TP server support for a custom listening port.
  • Matching support in l2tp-client to specify the destination port when connecting to the server.

This way, the server’s custom port and the client’s connection port setting can work together, making deployments more flexible and avoiding potential conflicts with the default L2TP port.

The same thing happened in BFD!
Now that we can see the sockets that have not been closed, these leaks are revealed. They probably have been there all the time (although random-source-port is a recent addition I think. it isn't even documented...).

When you discover things like this, it is best to create a support ticket. That will guarantee the matter gets attention (topics on the forum can be overlooked).
I made a ticket for the BFD issue, it was fixed in the next beta, but then BFD did not work at all anymore.
So make sure that you get a beta after it has been claimed to be fixed, and test it.

:joy:Thank you for your attention

Did you make a ticket? You can do it here:

yes Thank you