It was me a pleasure. I gained also deeper insight into this subject.
I would like to share my conclusions:
The decision chain for traffic originated at ROS is:
Routing Decision → Mangle (Output Chain) → Filter → Routing-Adjustment → Routing Rule
The Routing Decision requieres an active route which matches the destination (in our example the NTP Server). A default route is not required. From the resolved route ROS knows the egress interface and takes the ip-address defined on that interface (pref-source) as src-address. This procedure is required in order to accept or discard the reply packets.
The mangle rule may redirect traffic to an VRF, although Routing Decision has been already taken, and this is implemented in
Routing-Adjustment.
Finally,
Routing Rules may override everything. If e.g. traffic shall leave router at VRF1 and mangle rule redirects to VRF2, but Routing Rule redirects to VRF1, than it is working.
From this conclusions I derived a generic concept to control the ROS traffic. I defined a fake VRF, called FAKE, which contains just 1 loopback-interface with name loFAKE and without any routes inside. In the main table I placed a default-route with gateway=loFAKE (not the IP-Address on loFAKE). So, ROS always takes IP-Address on loopback-interface loFAKE as src-address. Mangle rules then redirect to the desired VRF. Routing Rules are used for other purposes like redirecting Winbox Traffic based on a IP-Address of an interface inside VRF, which ROS will use as response src-address. I implemented this concept last night and it works fine, at least for me. It may of course be modified to special needs.
It is a pitty that ROS does not offer VRF aware ROS services. But as we have now understood the issue we can build suitable workarounds.
Remark: As we use the VRF FAKE for resolving VRF related routes, we can use without any risk specific routes in the main table
/ip route
add dst-address=0.0.0.0/0 gateway=VLAN453
add dst-address=IP-of-NTP-Server gateway=loFAKE
add dst-address=192.168.23.0/24 gateway=10.0.0.1 comment=remote subnet at sstp-tunnel
VPN-client adds
dst-address=10.0.0.1 gateway=sstp1-in
The one and only client who can gain access to NTP-Server by these routes is the NTP-Client, because VRF FAKE is empty and we use mangle in outout-chain for redirecting traffic. This is in contrast to Routing Rules, where a client with spoofed src-address could gain access.
Greetings
Code: Select all
# generic template for controling ROS Services
#
# define loopback-interface "loFAKE" and set ip-address
#
/ip bridge
/interface bridge
add fast-forward=no name=loFAKE
/ip address
add address=10.11.11.10 interface=loFAKE network=10.11.11.10
#
# define VRF "FAKE"
#
/ip route vrf
add routing-mark=FAKE interface=loFAKE
#
# define default-route in table main using FAKE
#
/ip route
add dst-address=0.0.0.0/0 gateway=loFAKE
#
# define all mangle rules to control ROS Services
#
/ip firewall mangle
add chain=output src-address=10.11.11.10 dst-address=192.168.150.1 action=mark-routing new-routing-mark=mydesiredVRF
#
# set at destination a route to 10.11.11.10 to any interface of ROS