selective gateway

HI,
my router has two WAN IP addresses on the same physical port
and 5 LAN IP Addresses

/ip address> print 
Flags: X - disabled, I - invalid, D - dynamic 
 #   ADDRESS            NETWORK         INTERFACE                                                       
 0   192.168.10.2/24    192.168.10.0    ether4-LAN                                                      
 1   172.16.40.254/24   172.16.40.0     vlan-2                                                       
 2   172.16.50.254/24   172.16.50.0     vlan-1                                                                                                       
 5   37.xxx.xxx.237/29  37.xxx.xxx.232  ether1-WAN                                                      
 6   100.xx.xx.90/30    100.xx.xx.88    ether1-WAN

gateways are 37.xxx.xxx.233 and 100.xx.xx.89

I need that all packets from 172.16.50.0/24 (or from interface vlan-1) and dst-address= 77.xxx.xxx.7 use gateway 100.xx.xx.89
all other packets must use gateway 37.xxx.xxx.233

What I Have to do, Please?

Thank you in advance

Stefano

Mark all traffic from 172.16.50.0/24 and destination 77.xxx.xxx..7 with a routing mark (here you can be creative naming it), then add masquerade NAT rule and a default route for that mark with gateway 100.xx.xx.89.
I think you may also need to mark incoming traffic from 77.xxx.xxx..7 to 172.16.50.0/24 with that same routing mark and set up the proper routing for incoming traffic to match the masquerade rule (not sure about that, but it can’t hurt).
For the default route of the unmarked packets set default gateway to 37.xxx.xxx.233.

Thank you for your answer

What I think to do:

/ip firewall mangle
add action=mark-routing chain=prerouting disabled=no dst-address=77.xxx.xxx.7 new-routing-mark=to_voip passthrough=yes \
    src-address=172.16.50.0/24
add action=mark-routing chain=prerouting disabled=no dst-address=172.16.50.0/24 new-routing-mark=to_voip passthrough=yes \
    src-address=77.xxx.xxx.7
/ip route
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=100.xx.xx.89 routing-mark=to_voip scope=30 target-scope=10
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=37.xxx.xxx.233 scope=30 target-scope=10

is it right?
thank you

Seems ok… Try it and see if it works :laughing:
Maybe you need also routes defined for your gateways…
something like:

/ip route add dst-address=100.xx.xx.89/32 gateway=ether1-WAN distance=1
/ip route add dst-address=37.xxx.xxx.232/32 gateway=ether1-WAN distance=1

I tried a similar configuration at home, and it works.
Now I’ll try on that router.
Thank you