Multi ISP multi IP NAT forwarding problem

Good day everyone.

I have the following issue with my MikroTik device. Specifically, when traffic enters the router on, for example, WAN 3 and is intended for IP address 44.137.83.66 on port 80, the traffic arrives properly on ether3, but the response is sent out via ether1.

I will also include the configuration of my router here (or at least the parts that I believe are most relevant). If more information is needed or if you would like to see other parts of my router configuration, please let me know, and I will gladly provide the necessary details.

Thank you in advance for your help.


/interface bridge
add admin-mac=18:FD:74:BB:B8:8A auto-mac=no comment=defconf name=bridge

/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/ip pool
add name=default-dhcp ranges=192.168.88.10-192.168.88.254
add name=pool-ether5 ranges=172.22.9.1-172.22.15.254
add name=pool-ether6 ranges=172.22.17.1-172.22.23.1
add name=pool-ether7 ranges=172.22.25.1-172.22.31.254
add name=pool-ether8 ranges=172.22.33.1-172.22.39.254
add name=pool-ether9 ranges=172.22.41.1-172.22.47.254
add name=pool-ether10 ranges=172.22.49.1-172.22.55.254
add name=pool-wlan1 ranges=172.22.57.1-172.22.63.254
add name=pool-wlan2 ranges=172.22.65.1-172.22.71.254
add name=pool-wlan3 ranges=172.22.73.1-172.22.79.254
add name=pool-wlan4 ranges=172.22.81.1-172.22.87.254
add name=pool_L2tpServer ranges=172.22.89.1-172.22.95.254
add name=pool_L2tpClient ranges=172.22.97.1-172.22.103.254
add name=pool_SstpServer ranges=172.22.105.1-172.22.111.254
add name=pool_SstpClient ranges=172.22.113.1-172.22.119.254
add name=pool-OpenvpnServer ranges=172.22.121.1-172.22.127.254
add name=pool-OpenvpnClient ranges=172.22.135.254-172.22.192.1
add name=pool-PptpServer ranges=172.22.137.1-172.22.143.254
add name=pool-PptpClient ranges=172.22.145.1-172.22.151.254

/ip dhcp-server
add address-pool=default-dhcp interface=bridge name=defconf
add address-pool=pool-ether5 interface=ether5 name=ether5
add address-pool=pool-ether6 interface=ether6 name=ether6
add address-pool=pool-ether7 interface=ether7 name=ether7
add address-pool=pool-ether8 interface=ether8 name=ether8
add address-pool=pool-ether9 interface=ether9 name=ether9
add address-pool=pool-ether10 interface=ether10 name=ether10
add address-pool=pool-wlan1 interface=wlan1 name=wlan1
add address-pool=pool-wlan2 interface=wlan2 name=wlan2
add address-pool=pool-wlan3 interface=wlan3 name=wlan3
add address-pool=pool-wlan4 interface=wlan4 name=wlan4

/routing table
add disabled=no fib name=tabel_eth1
add disabled=no fib name=tabel_eth2
add disabled=no fib name=tabel_eth3
add disabled=no fib name=tabel_eth4

/interface list member
add interface=bridge list=LAN
add interface=ether1 list=WAN
add interface=ether2 list=WAN
add interface=ether3 list=WAN
add interface=ether4 list=WAN
add interface=ether5 list=LAN
add interface=ether6 list=LAN
add interface=ether7 list=LAN
add interface=ether8 list=LAN
add interface=ether9 list=LAN
add interface=ether10 list=LAN
add interface=wlan1 list=LAN
add interface=wlan2 list=LAN
add interface=wlan3 list=LAN
add interface=wlan4 list=LAN

/ip address
add address=192.168.88.1/24 interface=bridge network=192.168.88.0
add address=172.22.8.1/21 interface=ether5 network=172.22.8.0
add address=172.22.16.1/21 interface=ether6 network=172.22.16.0
add address=172.22.24.1/21 interface=ether7 network=172.22.24.0
add address=172.22.32.1/21 interface=ether8 network=172.22.32.0
add address=172.22.40.1/21 interface=ether9 network=172.22.40.0
add address=172.22.48.1/21 interface=ether10 network=172.22.48.0
add address=172.22.56.1/21 interface=wlan1 network=172.22.56.0
add address=172.22.64.1/21 interface=wlan2 network=172.22.64.0
add address=172.22.72.1/21 interface=wlan3 network=172.22.72.0
add address=172.22.80.1/21 interface=wlan4 network=172.22.80.0
add address=44.137.83.65/28 interface=ether3 network=44.137.83.64
add address=44.137.83.66/28 interface=ether3 network=44.137.83.64
add address=44.137.83.67/28 interface=ether3 network=44.137.83.64
add address=44.137.83.68/28 interface=ether3 network=44.137.83.64
add address=44.137.83.69/28 interface=ether3 network=44.137.83.64
add address=44.137.83.70/28 interface=ether3 network=44.137.83.64
add address=44.137.83.81/28 interface=ether4 network=44.137.83.80
add address=44.137.83.82/28 interface=ether4 network=44.137.83.80
add address=44.137.83.83/28 interface=ether4 network=44.137.83.80
add address=44.137.83.84/28 interface=ether4 network=44.137.83.80
add address=44.137.83.85/28 interface=ether4 network=44.137.83.80
add address=172.21.1.23/24 interface=ether1 network=172.21.1.0
add address=192.168.178.239/24 interface=ether2 network=192.168.178.0

/ip firewall filter
add action=accept chain=input comment="sstp tcp" dst-port=6443 in-interface=\
    ether1 protocol=tcp
add action=accept chain=input comment="sstp tcp" dst-port=6443 in-interface=\
    ether1 protocol=udp
add action=accept chain=input comment="openvpn tcp" dst-port=1194 \
    in-interface=ether1 protocol=tcp
add action=accept chain=input comment="openvpn udp" dst-port=1194 \
    in-interface=ether1 protocol=udp
add action=accept chain=input comment="l2tp " dst-port=500,4500,1701 \
    in-interface=ether1 protocol=udp
add action=accept chain=input comment=l2tp in-interface=ether1 protocol=l2tp
add action=accept chain=input comment="pptp gre" in-interface=ether1 \
    protocol=gre
add action=accept chain=input comment=pptp dst-port=1723 in-interface=ether1 \
    protocol=tcp
add action=accept chain=input comment=\
    "defconf: accept established,related,untracked" connection-state=\
    established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
    invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment=\
    "defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" \
    in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" \
    ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" \
    ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" \
    connection-state=established,related hw-offload=yes
add action=accept chain=forward comment=\
    "defconf: accept established,related, untracked" connection-state=\
    established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
    connection-state=invalid
add action=drop chain=forward comment=\
    "defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \
    connection-state=new in-interface-list=WAN

/ip firewall mangle
add action=mark-routing chain=prerouting disabled=yes in-interface-list=LAN \
    new-routing-mark=tabel_eth1 src-address=172.22.0.0/16
add action=mark-routing chain=prerouting disabled=yes in-interface-list=LAN \
    new-routing-mark=tabel_eth4 src-address=172.22.0.0/16
add action=mark-routing chain=prerouting disabled=yes in-interface-list=LAN \
    new-routing-mark=tabel_eth3 src-address=172.22.0.0/16
add action=mark-routing chain=prerouting disabled=yes in-interface-list=LAN \
    new-routing-mark=tabel_eth2 src-address=172.22.0.0/16
add action=mark-routing chain=prerouting disabled=yes in-interface-list=LAN \
    new-routing-mark=main src-address=172.22.0.0/16
add action=mark-connection chain=prerouting in-interface=ether1 \
    new-connection-mark=ether1_conn
add action=mark-connection chain=prerouting in-interface=ether2 \
    new-connection-mark=ether2_conn
add action=mark-connection chain=prerouting in-interface=ether3 \
    new-connection-mark=ether3_conn
add action=mark-connection chain=prerouting in-interface=ether4 \
    new-connection-mark=ether4_conn
add action=mark-routing chain=prerouting connection-mark=ether1_conn \
    disabled=yes in-interface-list=WAN new-routing-mark=tabel_eth1
add action=mark-routing chain=prerouting connection-mark=ether2_conn \
    disabled=yes in-interface-list=WAN new-routing-mark=tabel_eth2
add action=mark-routing chain=prerouting connection-mark=ether3_conn \
    disabled=yes in-interface-list=WAN new-routing-mark=tabel_eth3
add action=mark-routing chain=prerouting connection-mark=ether4_conn \
    disabled=yes in-interface-list=WAN new-routing-mark=tabel_eth4
add action=mark-routing chain=output new-routing-mark=main
add action=mark-routing chain=output connection-mark=ether1_conn \
    new-routing-mark=tabel_eth1
add action=mark-routing chain=output connection-mark=ether2_conn \
    new-routing-mark=tabel_eth2
add action=mark-routing chain=output connection-mark=ether3_conn \
    new-routing-mark=tabel_eth3
add action=mark-routing chain=output connection-mark=ether4_conn \
    new-routing-mark=tabel_eth4
add action=mark-routing chain=prerouting connection-mark=no-mark \
    in-interface=ether1 new-routing-mark=tabel_eth1
add action=mark-routing chain=prerouting connection-mark=no-mark \
    in-interface=ether2 new-routing-mark=tabel_eth2
add action=mark-routing chain=prerouting connection-mark=no-mark \
    in-interface=ether3 new-routing-mark=tabel_eth3
add action=mark-routing chain=prerouting connection-mark=no-mark \
    in-interface=ether4 new-routing-mark=tabel_eth4
add chain=prerouting in-interface-list=LAN src-address=172.22.47.247

/ip firewall nat
add action=dst-nat chain=dstnat connection-mark=ether3_conn dst-address=\
    44.137.83.66 dst-port=80 in-interface=ether3 protocol=tcp routing-mark=\
    tabel_eth3 to-addresses=172.22.47.247
add action=masquerade chain=srcnat out-interface-list=WAN
add action=masquerade chain=srcnat ipsec-policy=out,none out-interface-list=\
    WAN
add action=masquerade chain=srcnat out-interface=ether1
add action=masquerade chain=srcnat out-interface=ether2
add action=masquerade chain=srcnat out-interface=ether3
add action=masquerade chain=srcnat out-interface=ether4
add action=dst-nat chain=dstnat comment="minecraft tcp" dst-port=26565 \
    protocol=tcp to-addresses=172.22.47.250 to-ports=26565
add action=dst-nat chain=dstnat comment="minecraft udp" dst-port=26565 \
    protocol=udp to-addresses=172.22.47.250 to-ports=26565

/ip route
add disabled=yes distance=11 dst-address=0.0.0.0/0 gateway=172.21.1.1 \
    routing-table=main scope=30 suppress-hw-offload=no target-scope=10
add check-gateway=ping disabled=yes distance=12 dst-address=0.0.0.0/0 \
    gateway=192.168.178.1 routing-table=main scope=30 suppress-hw-offload=no \
    target-scope=10
add disabled=yes distance=13 dst-address=0.0.0.0/0 gateway=44.137.83.78 \
    routing-table=main scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=11 dst-address=0.0.0.0/0 gateway=172.21.1.1 \
    routing-table=main scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=11 dst-address=0.0.0.0/0 gateway=172.21.1.1 \
    routing-table=tabel_eth1 scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=12 dst-address=0.0.0.0/0 gateway=192.168.178.1 \
    routing-table=main scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=12 dst-address=0.0.0.0/0 gateway=192.168.178.1 \
    routing-table=tabel_eth2 scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=13 dst-address=0.0.0.0/0 gateway=44.137.83.78 \
    routing-table=main scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=13 dst-address=0.0.0.0/0 gateway=44.137.83.78 \
    routing-table=tabel_eth3 scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=14 dst-address=0.0.0.0/0 gateway=44.137.83.94 \
    routing-table=main scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=14 dst-address=0.0.0.0/0 gateway=44.137.83.94 \
    routing-table=tabel_eth4 scope=30 suppress-hw-offload=no target-scope=10

/routing rule
add action=lookup-only-in-table disabled=no routing-mark=tabel_eth1 table=\
    main
add action=lookup-only-in-table disabled=no routing-mark=tabel_eth2 table=\
    main
add action=lookup-only-in-table disabled=no routing-mark=tabel_eth3 table=\
    main
add action=lookup-only-in-table disabled=no routing-mark=tabel_eth4 table=\
    main/tool mac-server
set allowed-interface-list=LAN

Hi

Youi have to mangle incoming traffic to be able to send it back to the same interface.

Look there Dual wan: connection marks only when using mangle input

or search forum for "multi WAN" or "Dual WAN" or "multi ISP" etc., etc.

First of all, thank you very much for your response.
A acquaintance of mine also mentioned last night that the mangled rules were not correct.
I have since adjusted them to:

/ip firewall mangle
add action=mark-routing chain=prerouting disabled=yes in-interface-list=WAN \
    new-routing-mark=tabel_eth1 src-address=172.22.0.0/16
add action=mark-connection chain=prerouting in-interface=ether1 \
    new-connection-mark=ether1_conn
add action=mark-connection chain=prerouting in-interface=ether2 \
    new-connection-mark=ether2_conn
add action=mark-connection chain=prerouting in-interface=ether3 \
    new-connection-mark=ether3_conn
add action=mark-connection chain=prerouting in-interface=ether4 \
    new-connection-mark=ether4_conn
add action=mark-routing chain=prerouting connection-mark=ether2_conn \
    in-interface-list=!WAN new-routing-mark=tabel_eth2
add action=mark-routing chain=prerouting connection-mark=ether4_conn \
    in-interface-list=!WAN new-routing-mark=tabel_eth4
add action=mark-routing chain=prerouting connection-mark=ether3_conn \
    in-interface-list=!WAN new-routing-mark=tabel_eth3
add action=mark-routing chain=prerouting connection-mark=ether1_conn \
    in-interface-list=!WAN new-routing-mark=tabel_eth1
add action=mark-routing chain=output new-routing-mark=main
add action=mark-routing chain=output connection-mark=ether1_conn \
    new-routing-mark=tabel_eth1
add action=mark-routing chain=output connection-mark=ether2_conn \
    new-routing-mark=tabel_eth2
add action=mark-routing chain=output connection-mark=ether3_conn \
    new-routing-mark=tabel_eth3
add action=mark-routing chain=output connection-mark=ether4_conn disabled=yes \
    new-routing-mark=tabel_eth4
add action=accept chain=prerouting disabled=yes in-interface-list=LAN \
    src-address=172.22.47.247

Now, when I look with Packet Sniffer, traffic appears to be coming in properly on Ether3, and responses also seem to go through Ethernet3.
However, unfortunately, no website or similar is visible when trying to access my site from outside.
The web browser shows the error message: ERR_NETWORK_CHANGED.

I just wanted to let you know that it's finally working.
Thank you all so much for your help and feedback.

If you want to post your full config for review, I can take a look.
/export file=anynameyouwish (minus router serial number, any public WANIP information, keys, lease lists etc.)

Many times the config will appear to be working until it doesnt due to some more insidious config setups, or the performance is degraded and one doesnt necessarily notice.