marc.mmc
Goto Top

Mikrotik Connection Mark für Port Weiterleitungen

Ich verwende zwei Digitalisierungsboxen als WAN Uplink und habe auf dem Mikrotik PCC zum Load Balancing konfiguriert. Ich möchte nun über beide WAN IP's eine VPN Verbindung aufbauen können.

Genau hier liegt mein Problem. Ich muss eingehende Verbindungen markieren um sicherzugehen, dass die Antwort über das gleiche Gateway erfolgt. Die VPN Verbindung über die erste Digibox funktioniert (ether1-gateway). Die VPN Verbindung über die zweite Digibox (ether5-gateway) funktioniert nicht, da die Antwort des Servers über den falschen Gateway geroutet wird (ether1-gateway), da es mir nicht gelingt, die Portweiterleitungen richtig zu markieren. Ich dachte es geht über die forward chain aber es will mir nicht gelingen. Load Balancing über PCC funktioniert problemlos.
[admin@MikroTik RB3011] > /ip firewall mangle print 
Flags: X - disabled, I - invalid, D - dynamic 
 0  D ;;; special dummy rule to show fasttrack counters
      chain=prerouting 

 1  D ;;; special dummy rule to show fasttrack counters
      chain=forward 

 2  D ;;; special dummy rule to show fasttrack counters
      chain=postrouting 

 3    chain=prerouting action=mark-connection 
      new-connection-mark=no-mark passthrough=yes 
      connection-state=new log=no log-prefix=""   

 4    chain=input action=mark-connection 
      new-connection-mark=WAN1_conn passthrough=no 
      in-interface=ether1-gateway connection-mark=no-mark 
      log=no log-prefix=""   

 5    chain=input action=mark-connection 
      new-connection-mark=WAN2_conn passthrough=no 
      in-interface=ether5-gateway connection-mark=no-mark 
      log=no log-prefix=""   

 6    chain=prerouting action=mark-connection 
      new-connection-mark=WAN1_conn passthrough=no 
      in-interface=ether1-gateway connection-mark=no-mark 
      log=no log-prefix=""   

 7    chain=prerouting action=mark-connection 
      new-connection-mark=WAN2_conn passthrough=no 
      in-interface=ether5-gateway connection-mark=no-mark 
      log=no log-prefix=""   

 8    chain=forward action=mark-connection 
      new-connection-mark=WAN1_conn passthrough=no 
      in-interface=ether1-gateway connection-mark=no-mark 
      log=no log-prefix=""   

 9    chain=forward action=mark-connection 
      new-connection-mark=WAN2_conn passthrough=no 
      in-interface=ether5-gateway connection-mark=no-mark 
      log=no log-prefix=""   

10    chain=output action=mark-routing 
      new-routing-mark=to_WAN1 passthrough=yes 
      connection-mark=WAN1_conn log=no log-prefix=""   

11    chain=output action=mark-routing 
      new-routing-mark=to_WAN2 passthrough=yes 
      connection-mark=WAN2_conn log=no log-prefix=""   

12    chain=prerouting action=accept dst-address=10.10.1.0/2>
      in-interface=LAG1 log=no log-prefix=""   

13    chain=prerouting action=accept dst-address=10.10.2.0/2>
      in-interface=LAG1 log=no log-prefix=""   

14    chain=prerouting action=mark-connection 
      new-connection-mark=WAN1_conn passthrough=yes 
      dst-address-type=!local in-interface=LAG1 
      connection-mark=no-mark 
      per-connection-classifier=both-addresses:2/0 log=no 
      log-prefix=""   

15    chain=prerouting action=mark-connection 
      new-connection-mark=WAN2_conn passthrough=yes 
      dst-address-type=!local in-interface=LAG1 
      connection-mark=no-mark 
      per-connection-classifier=both-addresses:2/1 log=no 
      log-prefix=""   

16    ;;; Mark Connection to dnsomatic for WAN_1
      chain=prerouting action=mark-connection 
      new-connection-mark=WAN2_conn passthrough=yes 
      dst-address-type=!local 
      dst-address-list=host_dnsomatic log=no log-prefix=""   

17    chain=prerouting action=mark-routing 
      new-routing-mark=to_WAN1 passthrough=yes 
      in-interface=LAG1 connection-mark=WAN1_conn log=no 
      log-prefix=""   

18    chain=prerouting action=mark-routing 
      new-routing-mark=to_WAN2 passthrough=yes 
      in-interface=LAG1 connection-mark=WAN2_conn log=no 
      log-prefix=""  

Die Portweiterleitungen sind auf den Digiboxen konfiguriert (1701, 500 und 4500 UDP und ESP). Sobald ich für den VPN Client eine Route auf den zweiten Gateway lege, funktioniert es. Der Fehler liegt eindeutig daran, dass der Verbindungsaufbau des VPN Servers (also die Antwort) an den Default Gateway geht da die eingehende Verbindung nicht markiert wird.

Kann mir jemand bitte einen Tipp geben wo ich falsch liege?

Vielen Dank im Voraus
marc.mmc

Content-Key: 310206

Url: https://administrator.de/contentid/310206

Printed on: May 10, 2024 at 16:05 o'clock

Member: marc.mmc
marc.mmc Jul 19, 2016 at 21:31:40 (UTC)
Goto Top
Ich habe mittlerweile verstanden, dass man Verbindungen anscheinend nur markieren kann, wenn der Router selbst die Portweiterleitung macht.

Ich leite also nun die Ports für L2TP/IPSec von den Digiboxen auf den Router weiter und habe dort eine Portweiterleitung auf den Server eingerichtet. Die eingehende Verbindung wird auch korrekt markiert. Die Antwort des Servers geht jedoch immer an ether1-gateway und damit kommt natürlich keine Verbindung über die Digibox 2 an ether5-gateway zustande (Connection Mark WAN2_conn).

Ich verstehe nicht, wo mein Konfigurationsfehler liegt.
[admin@MikroTik RB3011] > /ip firewall nat print
Flags: X - disabled, I - invalid, D - dynamic 
 0    ;;; defconf: masquerade
      chain=srcnat action=masquerade out-interface=ether1-gateway log=no log-prefix=""   

 1    chain=srcnat action=masquerade out-interface=ether5-gateway log=no log-prefix=""   

 2    chain=dstnat action=dst-nat to-addresses=10.10.10.1 protocol=udp in-interface=ether1-gateway dst-port=500,4500 log=no log-prefix=""   

 3    chain=dstnat action=dst-nat to-addresses=10.10.10.1 protocol=ipsec-esp in-interface=ether1-gateway log=no log-prefix=""   

 4    chain=dstnat action=dst-nat to-addresses=10.10.10.1 protocol=udp in-interface=ether5-gateway dst-port=500,4500 log=no log-prefix=""   

 5    chain=dstnat action=dst-nat to-addresses=10.10.10.1 protocol=ipsec-esp in-interface=ether5-gateway log=no log-prefix=""  

[admin@MikroTik RB3011] > /ip firewall mangle print
Flags: X - disabled, I - invalid, D - dynamic 
 0  D ;;; special dummy rule to show fasttrack counters
      chain=prerouting 

 1  D ;;; special dummy rule to show fasttrack counters
      chain=forward 

 2  D ;;; special dummy rule to show fasttrack counters
      chain=postrouting 

 3    chain=prerouting action=mark-connection new-connection-mark=no-mark passthrough=yes connection-state=new log=no log-prefix=""   

 4    chain=prerouting action=mark-connection new-connection-mark=WAN1_conn passthrough=yes in-interface=ether1-gateway 
      connection-mark=no-mark log=no log-prefix=""   

 5    chain=prerouting action=mark-connection new-connection-mark=WAN2_conn passthrough=yes in-interface=ether5-gateway 
      connection-mark=no-mark log=no log-prefix=""   

 6    chain=input action=mark-connection new-connection-mark=WAN1_conn passthrough=yes in-interface=ether1-gateway connection-mark=no-mark 
      log=no log-prefix=""   

 7    chain=input action=mark-connection new-connection-mark=WAN2_conn passthrough=yes in-interface=ether5-gateway connection-mark=no-mark 
      log=no log-prefix=""   

 8    chain=forward action=mark-connection new-connection-mark=WAN1_conn passthrough=yes in-interface=ether1-gateway log=no log-prefix=""   

 9    chain=forward action=mark-connection new-connection-mark=WAN2_conn passthrough=yes in-interface=ether5-gateway log=no log-prefix=""   

10    chain=output action=mark-routing new-routing-mark=to_WAN1 passthrough=yes connection-mark=WAN1_conn log=no log-prefix=""   

11    chain=output action=mark-routing new-routing-mark=to_WAN2 passthrough=yes connection-mark=WAN2_conn log=no log-prefix=""   

12    chain=prerouting action=accept dst-address=10.10.1.0/24 in-interface=LAG1 log=no log-prefix=""   

13    chain=prerouting action=accept dst-address=10.10.2.0/24 in-interface=LAG1 log=no log-prefix=""   

14    chain=prerouting action=mark-connection new-connection-mark=WAN1_conn passthrough=yes dst-address-type=!local in-interface=LAG1 
      connection-mark=no-mark per-connection-classifier=both-addresses:2/0 log=no log-prefix=""   

15    chain=prerouting action=mark-connection new-connection-mark=WAN2_conn passthrough=yes dst-address-type=!local in-interface=LAG1 
      connection-mark=no-mark per-connection-classifier=both-addresses:2/1 log=no log-prefix=""   

16    ;;; Mark Connection to dnsomatic for WAN_2
      chain=prerouting action=mark-connection new-connection-mark=WAN2_conn passthrough=yes dst-address-type=!local 
      dst-address-list=host_dnsomatic log=no log-prefix=""   

17    chain=prerouting action=mark-routing new-routing-mark=to_WAN1 passthrough=yes in-interface=LAG1 connection-mark=WAN1_conn log=no 
      log-prefix=""   

18    chain=prerouting action=mark-routing new-routing-mark=to_WAN2 passthrough=yes in-interface=LAG1 connection-mark=WAN2_conn log=no 
      log-prefix=""  

Und zuletzt der relevante Teil zum Routing:
[admin@MikroTik RB3011] > /ip route print detail
Flags: X - disabled, A - active, D - dynamic, C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme, 
B - blackhole, U - unreachable, P - prohibit 
 0 A S  dst-address=0.0.0.0/0 gateway=10.10.1.1 gateway-status=10.10.1.1 reachable via  ether1-gateway check-gateway=ping distance=1 scope=3>
        target-scope=10 routing-mark=to_WAN1 

 1 A S  dst-address=0.0.0.0/0 gateway=10.10.2.1 gateway-status=10.10.2.1 reachable via  ether5-gateway check-gateway=ping distance=1 scope=3>
        target-scope=10 routing-mark=to_WAN2 

 2 A S  dst-address=0.0.0.0/0 gateway=10.10.1.1 gateway-status=10.10.1.1 reachable via  ether1-gateway check-gateway=ping distance=1 scope=3>
        target-scope=10 

 3   S  dst-address=0.0.0.0/0 gateway=10.10.2.1 gateway-status=10.10.2.1 reachable via  ether5-gateway check-gateway=ping distance=2 scope=3>
        target-scope=10

Anmerkung: Zu Testzwecken gehen hier beide Portweiterleitungen an den gleichen Server. Das soll sich später ändern.

Für einen Hinweis wäre ich dankbar. Ich verstehe nicht, warum die Antwort des Servers von 10.10.10.1 zwar an den richtigen Client adressiert ist aber trotz der Markierung der eingehenden Verbindung mit WAN2_conn an ether1-gateway geroutet wird.

Viele Grüße
marc.mmc