Greetings,
I've stumbled upon a strange problem when running on-up scripts for a PPP profile:
I need to install routes to a PPP user into a specific routing table in order to make a PBR policy work.
I've crafted a on-up script as follows:
{
:local remad $"caller-id"
:local msg "Admin VPN login $user from $remad"
:local RemoteAddress $"remote-address"
:local LocalInterface [/interface get $interface name]
/ip/route/add dst-address=$RemoteAddress gateway=$LocalInterface routing-table=rtab-special comment="Route to special for $user"
}
And it works for users in /ppp/secrets -- I see the route to the client in the appropriate routing table with the gateway listed as ""
But when a RADIUS user authenticates with a "user@domain.int" username the script fails throwing a weird error "invalid or unexpected argument base".
After debugging I've finally realized that the user's dynamic interface is named "l2tp-user@domain.int" and the 'tik's scripting doesn't like the "@" in the interface name as it refers to a VRF, so a "gateway=l2tp-user@domain.int" throws an error
Is there a way to make this work?
Indeed, if a dynamic route with the interface as gateway is always automatically added to the main routing table, maybe as a workaround you can use the copy trick, that copies the route of the main table, while changing the routing table name?
/ip route add copy-from=[/ip route find where gateway="$LocalInterface" dynamic !disabled routing-table=main] \
dst-address=$RemoteAddress routing-table=rtab-special comment="Route to special for $user"
Good idea but unfortunately -- no go
:
[Mikrotik] /ppp/profile> :put [/ip route find where dst-address=172.16.126.98/32 and dynamic=yes and routing-table=main]
*201D0260
[Mikrotik] /ppp/profile> /ip/route/add copy-from=[/ip route find where dst-address=172.16.126.98/32 and dynamic=yes and routing-table=main] routing-table=rtab-special dst-address
=172.16.126.98/32
failure: invalid route type
Any idea what is "route type" and where to set it? 
Ah
I think in this case the route type is what shown with the "C" flag: the route is a connected route, `copy-from" keep the "connected" flag in the copy, and unfortunately we cannot explicitly add connected routes. So what I wrote above won't work.