A
A
allfools2015-07-31 12:13:51
Mikrotik
allfools, 2015-07-31 12:13:51

Mikrotik! How to redirect outgoing traffic on a specific port to another gateway?

I want to immediately apologize for the possible headache after reading the essence of the problem.
And the essence is as follows:
- There are 2 offices.
- Communication between offices is configured using 2 microtics (951g) and EoIP over VPN
Both gateways see each other and generally have a single address space, love and brotherhood.
- On the side of Mikrotik "A" there is a server. (WinSrv 2012 with 1c via RDP, as well as other accounting stray and Kerio mail server) - 1 network interface sticks out in it.
- The provider on the side of Mikrotik "A" cannot register a PTR record, but the provider on the side of Mikrotik "B" can.
- How to make mail traffic go to the outside world through Mikrotik "B", and the rest through Mikrotik "A"?
Just in case, let it be like this:
Local network 192.168.89.0/24
Mikrotik "A" - 1.1.1.1.
Mikrotik "B" - 2.2.2.2
I understand that there may be problems if A and PTR records are at different addresses? But rewriting A record to Mikrotik "B" and then forwarding it inside the LAN is not a problem.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
G
Grustnui, 2015-08-06
@Grustnui

I will describe in more detail how to do what Ruslan Fedoseev wrote .
Let the mailer be 192.168.88.20.
Mikrotik A - 192.168.88.1.
Mikrotik B - 192.168.88.10.
Let's mark all connections from the mail server out to the 25th port.
/ip firewall mangle
add action=mark-routing chain=prerouting dst-port=25 dst-address=!192.168.88.0/24 new-routing-mark=\
"SMTP Server" protocol=tcp src-address=192.168.88.20
To save resources, you can first mark the connection, and then change the routing table for the connection packets. In this case, the router will not check all the packets passing through it, but will first look at the connection label, and if the connection is marked, then all its packets will be labeled that they should go to another routing table.
/ip firewall mangle
add action=mark-connection chain=prerouting dst-address=!192.168.88.0/24 \
dst-port=25 new-connection-mark=SMTP_Connect protocol=tcp src-address=\
192.168.88.20
add action= mark-routing chain=prerouting connection-mark=SMTP_Connect \
new-routing-mark="SMTP Server" src-address=192.168.88.20
Let's create another SMTP Server routing table and specify the default gateway Mikrotik B for it
/ip route
add distance=1 gateway=192.168.88.10 routing-mark="SMTP Server"
In theory, traffic through the 25th port should go through B.

R
Ruslan Fedoseev, 2015-07-31
@martin74ua

mark the traffic to port 25 in the mangle table, and route the marked traffic through another routing table, in which the default is provider B.

I
Ivan, 2015-07-31
@LiguidCool

Why not send all mailer traffic through B?
Honestly, the essence of the problem is not very clear, where is the question?

A
allfools, 2015-07-31
@allfools

Yes, all of it is possible.
The essence of the problem: how to tell the mailer that you need to go to the Internet through "B"?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question