usually you would apply it to the ingress interface where the source traffic is flowing into, however like you pointed out the source traffic in this case is not flowing into any interface because it’s being generated by the router itself. Have you tried applying it to the loopback interface?
It depends on the usecase, but you could do it “the other way”. Policy route traffic traversing your router.
I see some problems with your approach, and you may observe some unpredictable behaviour. If you want to have a VPN tunnel, DHCP relay agent and other “user related” traffic generated in your router you probably want it to use the same routing table as the rest of the “user related” traffic.
We have BGP router with multiple uplinks that have default route. We want that router to respond to pings on any of the IP-addresses that are used for interconnections.
For that purpose we usually set up separate routing table with different default gateway for each address.
If you ping 192.168.1.2 on a BGP router from somewhere, it may or may not come in from 192.168.1.1. Is this for monitoring connectivity between the BGP peers?
If you have multiple uplinks then usually traffic to the same network is routed via same gateway.
If traffic from router to my ip (when i try to connect to router via ssh) comes via eth0 but for some reasons (due to technical problems) i can’t be reached via eth0 -> i can’t connect to router.
Since router has multiple IP’s (one for each uplink), i want that if i connect from internet to router’s IP1 then ssh traffic from router to me must go via eth0. If i connect from internet to router’s IP2 then ssh traffic from router to me must go via eth1.
In this case if uplink with IP1 doesn’t work for some reasons, i will be able to connect to IP2.