Hmm, interesting, but this definitely works on RouterOS.
How can I implement this then? Let me repeat and clarify what I am looking for. This is my current routing table:
vyos@SunGate1:~$ show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
F - PBR, f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
S>* 0.0.0.0/0 [210/0] via 181.183.144.1, eth0.2, weight 1, 00:00:10
C>* 10.227.1.0/24 is directly connected, eth0.5, 00:58:04
C>* 10.227.2.0/24 is directly connected, eth0.4, 00:58:05
C>* 10.227.79.0/24 is directly connected, eth0.3, 00:58:05
C>* 10.227.80.0/24 is directly connected, eth0.10, 00:58:03
O 192.0.2.226/31 [110/100] is directly connected, wg0, weight 1, 00:57:51
C>* 192.0.2.226/31 is directly connected, wg0, 00:57:55
C>* 192.168.222.0/24 is directly connected, eth0.11, 00:58:03
C>* 192.168.223.0/24 is directly connected, eth0.12, 00:58:02
C>* 181.183.144.0/21 is directly connected, eth0.2, 00:00:11
vyos@SunGate1:~$
I want that if the source address of any packet (local or not local) is 192.0.2.0/24, the default route should not be used. Instead it should be routed via nexthop 192.0.2.226.
As I said, in RouterOS I could solve this by removing the default gateway from this table and put it into a separate table. The rules would then consult the main table and then the default gw tables (based on source address).
Maybe there is a better/different way to do this in VyOS…