IPIP Tunnel Problem in 4 wan and incoming connections

Hello to all
I have a some server inside my network, listening on port 8800 and 443 and … , and i would like to be able to accept incoming connections from all wan than mean wan1 and wan2 and wan 3 and wan 4 . and i use the below codes .
Now everything work fine except IPIP tunnels , i have also 44 Tunnel but only the active wan Tunnel will be up that mean wan 1 Tunnels will be up and when disable wan1 , wan2 will be active and Tunnels wan2 will be up and when disable wan 2 , wan 3 will be active and tunnel wan 3 will be up and … .
So whats the problem and how can i fix this problem ? i want all my tunnel will be active without disabling wans .


# redirect incoming traffic in wan1 and wan2 and wan 3 and wan 4 to the local servers
/ip firewall nat add chain=dstnat protocol=tcp dst-port=8800 in-interface=wan1 action=dst-nat to-addresses=192.168.0.1 to-ports=80
/ip firewall nat add chain=dstnat protocol=tcp dst-port=22 in-interface=wan2 action=dst-nat to-addresses=192.168.0.12 to-ports=22
/ip firewall nat add chain=dstnat protocol=tcp dst-port=5060 in-interface=wan3 action=dst-nat to-addresses=192.168.0.14 to-ports=5060



# what comes from wan1, gets out from wan1
/ip firewall mangle add action=mark-connection chain=input in-interface=PPPOE-ISP1 new-connection-mark=wan1_conn passthrough=yes disabled=no comment="in wan1,out wan1"
/ip firewall mangle add action=mark-routing chain=output connection-mark=wan1_conn new-routing-mark=wan1_traffic passthrough=no disabled=no comment="in wan1,out wan1"

# what comes from wan2, gets out from wan2
/ip firewall mangle add action=mark-connection chain=input in-interface=PPPOE-ISP2 new-connection-mark=wan2_conn passthrough=yes disabled=no comment="in wan2,out wan2"
/ip firewall mangle add action=mark-routing chain=output connection-mark=wan2_conn new-routing-mark=wan2_traffic passthrough=no disabled=no comment="in wan2,out wan2"

# what comes from wan3, gets out from wan3
/ip firewall mangle add action=mark-connection chain=input in-interface=PPPOE-ISP3 new-connection-mark=wan3_conn passthrough=yes disabled=no comment="in wan3,out wan3"
/ip firewall mangle add action=mark-routing chain=output connection-mark=wan3_conn new-routing-mark=wan3_traffic passthrough=no disabled=no comment="in wan3,out wan3"

# what comes from wan4, gets out from wan4
/ip firewall mangle add action=mark-connection chain=input in-interface=PPPOE-ISP4 new-connection-mark=wan4_conn passthrough=yes disabled=no comment="in wan4,out wan4"
/ip firewall mangle add action=mark-routing chain=output connection-mark=wan4_conn new-routing-mark=wan4_traffic passthrough=no disabled=no comment="in wan4,out wan4"


# port forwards from wan1, gets out from wan1
/ip firewall mangle add action=mark-connection chain=forward in-interface=PPPOE-ISP1 connection-state=new new-connection-mark=wan1_pfw passthrough=no disabled=no comment="pfw wan1, out wan1"
/ip firewall mangle add action=mark-routing chain=prerouting in-interface=ETH1-LAN connection-mark=wan1_pfw new-routing-mark=wan1_traffic passthrough=no disabled=no comment="pfw wan1, out wan1"

# port forwards from wan2, gets out from wan2
/ip firewall mangle add action=mark-connection chain=forward in-interface=PPPOE-ISP2 connection-state=new new-connection-mark=wan2_pfw passthrough=no disabled=no comment="pfw wan2, out wan2"
/ip firewall mangle add action=mark-routing chain=prerouting in-interface=ETH1-LAN connection-mark=wan2_pfw new-routing-mark=wan2_traffic passthrough=no disabled=no comment="pfw wan2, out wan2"

# port forwards from wan3, gets out from wan3
/ip firewall mangle add action=mark-connection chain=forward in-interface=PPPOE-ISP3 connection-state=new new-connection-mark=wan3_pfw passthrough=no disabled=no comment="pfw wan3, out wan3"
/ip firewall mangle add action=mark-routing chain=prerouting in-interface=ETH1-LAN connection-mark=wan3_pfw new-routing-mark=wan3_traffic passthrough=no disabled=no comment="pfw wan3, out wan3"

# port forwards from wan4, gets out from wan4
/ip firewall mangle add action=mark-connection chain=forward in-interface=PPPOE-ISP4 connection-state=new new-connection-mark=wan4_pfw passthrough=no disabled=no comment="pfw wan4, out wan4"
/ip firewall mangle add action=mark-routing chain=prerouting in-interface=ETH1-LAN connection-mark=wan4_pfw new-routing-mark=wan4_traffic passthrough=no disabled=no comment="pfw wan4, out wan4"



# routing rules for wan1_traffic and wan2_traffic and wan3_traffic and wan4_traffic 
/ip route add dst-address=0.0.0.0/0 gateway=PPPOE-ISP1 distance=1 routing-mark=wan1_traffic disabled=no
/ip route add dst-address=0.0.0.0/0 gateway=PPPOE-ISP2 distance=1 routing-mark=wan2_traffic disabled=no
/ip route add dst-address=0.0.0.0/0 gateway=PPPOE-ISP3 distance=1 routing-mark=wan3_traffic disabled=no
/ip route add dst-address=0.0.0.0/0 gateway=PPPOE-ISP4 distance=1 routing-mark=wan4_traffic disabled=no



/ip route add dst-address=0.0.0.0/0 gateway=PPPOE-ISP1 distance=1 check-gateway=ping disabled=no
/ip route add dst-address=0.0.0.0/0 gateway=PPPOE-ISP2 distance=2 check-gateway=ping disabled=no
/ip route add dst-address=0.0.0.0/0 gateway=PPPOE-ISP3 distance=3 check-gateway=ping disabled=no
/ip route add dst-address=0.0.0.0/0 gateway=PPPOE-ISP4 distance=4 check-gateway=ping disabled=no

You don’t need the “port forwards from..” rules, the generic “what comes from” are enough.

About ipip tunnels , if I have correctly undertook your setup from your few lines, you need to routing mark them also in some way. Now only tunnels working on the slowest distance of main routing table work ..which is exactly what you are asking with your configuration.

Dear bajodel
Thanks for your reply . could you please guide me about routing mark for IPIP Tunnels ?
Please help me.
Thank you

Do you really have 44 tunnels ..or it’s a typo?

Anyway.. it depends on what you want achieve. I would try to balance the 4 (or 44) tunnels on the 4 wans, so I’d divide the tunnels in 4 group creating 4 address lists (wan1tunnels, wan2tunnels.. ..) ..with the ipip endpoint ips. In mangle I’d set route marks using dst address list.