Hi all!
I have two internet links here, named wan1 and wan2 in mikrotik (RB450G OS 5.5), and both are working.
I also have a linux server inside my network, listening on port 22, and i would like to be able to accept incomin connections from both wan1 and wan2. There are no firewall rules in this server.
First, i added a nat rule to redirect external traffic to ssh host:
/ip firewall nat add chain=dstnat protocol=tcp dst-port=22 in-interface=wan1 action=dst-nat to-addresses=192.168.0.1 to-ports=22
/ip firewall nat add chain=dstnat protocol=tcp dst-port=22 in-interface=wan2 action=dst-nat to-addresses=192.168.0.1 to-ports=22
Then i added a masquerade rule for my internal hosts to be able to access the internet:
/ip firewall nat add chain=srcnat src-address=192.168.0.0/24 action=masquerade disabled=no
Then i marked the traffic comming from both wan1 and wan2 to return from the same interface:
/ip firewall mangle add action=mark-connection chain=input in-interface=wan1 new-connection-mark=wan1_conn passthrough=yes disabled=no
/ip firewall mangle add action=mark-routing chain=output connection-mark=wan1_conn new-routing-mark=wan1_traffic passthrough=no disabled=no
/ip firewall mangle add action=mark-connection chain=input in-interface=wan2 new-connection-mark=wan2_conn passthrough=yes disabled=no
/ip firewall mangle add action=mark-routing chain=output connection-mark=wan2_conn new-routing-mark=wan2_traffic passthrough=no disabled=no
Then i marked the forwarded connections to return from the same interface:
/ip firewall mangle add action=mark-connection chain=forward in-interface=wan1 connection-state=new new-connection-mark=wan1_pfw passthrough=no disabled=no
/ip firewall mangle add action=mark-routing chain=prerouting connection-mark=wan1_pfw new-routing-mark=wan1_traffic passthrough=no disabled=no
/ip firewall mangle add action=mark-connection chain=forward in-interface=wan2 connection-state=new new-connection-mark=wan2_pfw passthrough=no disabled=no
/ip firewall mangle add action=mark-routing chain=prerouting connection-mark=wan2_pfw new-routing-mark=wan2_traffic passthrough=no disabled=no
Then i added the routes to the marked packets (the default routes are using wan1 (distance2) and wan2 (distance 3)):
/ip route add dst-address=0.0.0.0/0 gateway=wan1 distance=1 check-gateway=ping routing-mark=wan1_traffic disabled=no
/ip route add dst-address=0.0.0.0/0 gateway=wan2 distance=1 check-gateway=ping routing-mark=wan2_traffic disabled=no
I think these steps covered everything needed to make this work, but look what is happening:
If i try to connect to port 22 using a telnet client from an external network using wan1 ip, it connects and i receive the message "OpenSSH Server version ...." from the server
telnet <wan1_ip> 22
Connected to <wan1_ip>.
Escape character is '^]'.
SSH-2.0-OpenSSH_5.6
If i try to connect to port 22 using a ssh client from an external network using wan1 ip, it works as expected
If i try to connect to port 22 using a telnet client from an external network using wan2 ip, it connects but i don´t receive any message from the server
telnet <wan2_ip> 22
Trying <wan2_ip>...
Connected to <wan2_ip>.
Escape character is '^]'.
If i try to connect to port 22 using a ssh client from an external network using wan2 ip, it doesn´t connect. It doesn´t report an error, just stay waiting forever...
Do you have any clues about what can be happening, or what should i do to investigate it?
Regards,
Fabiano