Well, changing the script allows to add the desired realms in the username, however the establishing of the l2tp tunnel fails before it comes to the authentication phase:
Oct 16 18:56:15 l2tps Incoming L2TP packet from x.x.52.55 13660
Oct 16 18:56:15 l2tps L2TP: Control connection 0x803252610 terminated: 0 ()
Oct 16 18:56:21 l2tps Incoming L2TP packet from x.x.52.54 13660
Oct 16 18:56:21 l2tps L2TP: Control connection 0x803252310 terminated: 0 ()
Oct 16 18:56:26 l2tps L2TP: Control connection 0x803252610 destroyed
Oct 16 18:56:32 l2tps L2TP: Control connection 0x803252310 destroyed
Oct 16 18:56:47 l2tps Incoming L2TP packet from x.x.52.55 13660
Oct 16 18:56:47 l2tps L2TP: Control connection 0x803252310 terminated: 0 ()
Oct 16 18:56:58 l2tps L2TP: Control connection 0x803252310 destroyed
When capturing the L2TP traffic on the LAC I can see it sends out the SccReq (Start Control Request) but is immediately turned down with a StopCCN (Stop Control Notification). The AVP Error-Result-Code is 0x4 : Requester is not authorized to establish a control connection. Normally this would mean I need to whitelist the LAC IP with a secret, but in pfSense I can't do this.
I checked and you actually use mpd so I checked /var/etc/l2tp-vpn/mpd.conf. What I'm missing here is a peer config, something like:
set l2tp peer x.x.52.55
set l2tp hostname $lns_hostname
set l2tp secret $lns_secret
After adding this, I killed mpd manually and restarted and then I'm able to connect:
Oct 16 19:34:24 l2tps [l2tp_b-1] IPCP: state change Req-Sent --> Ack-Sent
Oct 16 19:34:24 l2tps [l2tp_b-1] IPCP: rec'd Configure Ack #2 (Ack-Sent)
Oct 16 19:34:24 l2tps [l2tp_b-1] IPADDR 192.168.2.1
Oct 16 19:34:24 l2tps [l2tp_b-1] IPCP: state change Ack-Sent --> Opened
Oct 16 19:34:24 l2tps [l2tp_b-1] IPCP: LayerUp
Oct 16 19:34:24 l2tps [l2tp_b-1] 192.168.2.1 -> 192.168.2.16
Oct 16 20:18:24 pfSense l2tps: [l2tp_b-1] IFACE: No interface to proxy arp on for 192.168.2.16
Oct 16 20:18:24 pfSense l2tps: [l2tp_b-1] IFACE: Up event
Oct 16 20:18:24 pfSense l2tps: [l2tp_b-1] IFACE: Rename interface ng0 to l2tp1
Oct 16 20:18:24 pfSense l2tps: [l2tp_b-1] IFACE: Add group l2tp to ng0
This is odd, the manpage of mpd5.8 says:
Sets the peer IP address and port for the L2TP connection. This command applies to both incoming and outgoing connections. For outgoing connections, this command is required in order to specify where to connect to. For incoming connections, this command is optional; if not given, mpd accepts incoming connections from any host. Otherwise, only connections from the stated IP address (and, optionally, port) are allowed.
Ergo: the patch for the username (realm) works, can you commit this for future releases?
But it's not possible to implement a l2tp peer (plus secret, this actually doesn't seem to do anything). Should I raise a separate ticket for this config issues since this is an authentication ticket?