(and don’t have any default route in the main routing table). I get the following:
/ping 192.168.0.1 src-address=10.0.2.1
no route to host
no route to host
which means it doesn’t look in the test routing table where I added the route but in the main routing table where there isn’t any route for that network. Is there any way to solve this problem?
delete the lookup rule i route table, mangle rule for routing does what’s needed, and and table lookup just messes things, remmber to reboot after that, i had the same situation i removed route lookup and rebooted and it started to working. Also if you have multiple ips, and you want to start connection from the router (because normal situation is when you have multiple ips and for it a routing mark, when you ping that ip from other device then this rule will work) besides that marking rule for src-address you need a netmap/srcnat rule that will make sure that all connections from this router will be nated to this specific address (you can src-address-type=local for that)
Allthough there was one more thing missing, you have to have a route for the network in the 192.168.0.0/24 in the main table. That route wasn’t used but unless it was there it would not check the alternative routing table for a route for that network. I noticed this I didn’t have any default route in the default routing table.
you have right i didn’t notice it before but yes if you don’t have route in main table even if it’s pointing on strange gateway, system won’t check alternate routing tables.