Two carriers with public ips and one mikrotik

Hello, thanks for the forum. It is a pleasure to be part of it.

I’m an ISP and I work using PPPoE with my clients, delivering public ips. I have two carriers that give me one / 24 public ips each. I’m looking for make each ip range go out through their wan using dynamic pppoe: depending on the assigned ip to the client, must go out through one wan or another.

I have solved that issue by making static routes such that:

IP-ROUTES: I add the route for each wan, but in one of them I put marked in Routing Mark.
In RULES I add the ips of that wan and assign it the Routing Mark table.
In this way, I get the upstream traffic of that secondary range to go out through it, and not through the main one.

THE PROBLEM: now there is no access to my own ips, I mean, I do not access the public IP from any of my public ips to other of my public ips. From outside my network without problem. This affects, for example, several clients that have two houses connected to this mikrotik and now cannot access ftp servers between them.

I give an example:

CARRIER1: 87.100.100.1/24
CARRIER2: 88.100.100.1/24

CLIENT1: 87.100.100.2/32 (Or any ip, from carrier1 or 2)
CLIENT2: 88.100.100.2/32 (Or any ip, from carrier1 or 2)

CLIENT1 tries to access CLIENT2. Does not agree.

We deactivated in IP-ROUTE the rule that Routing Mark has and now they do access each other but the upload traffic of all now leaves through the same wan; the main one.

What’s going on?

Thank you and sorry for my bad english.

:frowning: :frowning: :frowning:

Perhaps a diagram would help??

I have given an example but I will try to explain better.

Let’s assume that we are going to use two ethernet ports as input, each port is a provider.

ETH1: 84.54.54.1/24
ETH2: 84.54.55.1/24

Between the two providers we have 512 public ips. Good.

Now, we are going to supply those public ips by PPPoE to our clients using the ethernet3 port. We already have the pools created and they are supplied perfectly.

I create the main route for the first provider in IP-> Routes:

Dst. Address: 0.0.0.0/0 Gateway: 84.54.54.1 (Reachable ETH1) Distance: 1 Scope: 30 Target Scope: 10

I create the secondary route for the second provider in IP-> Routes:

Dst. Address: 0.0.0.0/0 Gateway: 84.54.55.1 (Reachable ETH2) Distance: 1 Scope: 30 Target Scope: 10 Routing Mark: SECONDARY

I assign the ips of the second provider to the markup in IP->Routes->Rules:

Src. Address: 84.54.55.0/24 Dst. Address: 0.0.0.0/0 Action: lookup Table: SECONDARY

Everything works well.


Now, the problem… A client with ip 84.54.54.6, for example, tries to access to a server hosted by another client with ip 84.54.55.96. There is no access.

¿Solution? Thanks.

What’s going on is that each PPPoE tunnel becomes a “connected subnet”, i.e. a route with distance=0 to its remote-address is added to your routing table whenever the client connects. So the packets from a client in one /24 (subnet A) to a client in the same subnet A or in the other /24 (subnet B) would normally take a direct path, bypassing the WANs. But your policy routing (by means of /ip route rule rows) has (probably) changed this only for packets from clients in subnet B (those which are instructed to use a specific routing table to go out via the corresponding WAN interface), but as you say that for source subnet A you keep using the main routing table, it means it is used also for packets towards subnet B, and in the main routing table, the dynamically added routes mentioned above override the default route via WAN A’s gateway. So packets from subnet A to subnet B still take the shortcut whilst packets from subnet B to subnet A go out the WAN and come back via WAN A. So if you use some firewall rules referring to in-interface(-list), they may not match on the traffic taking a different-than-expected way.

On the other hand, if two clients in subnet B want to talk to each other, your routing rules request that everything from subnet B, including packets to another subnet B address, go out the WAN B, and the ISP B may not loop the packets back to your WAN since from the ISP’s perspective they should have never received them.

But all the above is just a speculation. If you want a more useful advice, instead of posting sad smileys, post your current configuration, anonymized the way suggested in my automatic signature just below.

Also, instead of choosing routing tables by means of /ip route rule rows, moving WAN B and all the PPPoE interfaces using that WAN to a separate VRF group could be a simpler way, however not knowing the other circumstances (some public IPs may be used to NAT clients which do not require public IP addresses) it is hard to say what is the best way.

 /ip pool
add name=POOL next-pool=none ranges=84.54.54.2-84.54.55.254

/ppp profile
add dns-server=8.8.8.8,8.8.4.4 local-address=84.54.24.1 name=internet \
    only-one=yes remote-address=POOL

/interface bridge port
add bridge=bridge1 interface=ether3
add bridge=bridge1 interface=ether4

/ip address
add address=192.168.1.2/24 comment=WAN_XTRA interface=ether1 network=\
    192.168.1.0
add address=192.168.10.2/24 comment=WAN_AIRE interface=sfp-sfpplus1 network=\
    192.168.10.0
add address=84.54.54.1/24 comment=PUB_AIRE interface=bridge1 network=\
    84.54.54.0
add address=84.54.55.1/24 comment=PUB_XTRA interface=bridge1 network=\
    84.54.55.0

/ip firewall filter
add action=drop chain=input comment="drop dns" dst-port=53 in-interface=\
    sfp-sfpplus1 protocol=udp
add action=drop chain=input comment="drop dns" dst-port=53 in-interface=\
    ether1 protocol=udp
add action=drop chain=input comment="drop dns2" dst-port=53 in-interface=\
    sfp-sfpplus1 protocol=tcp
add action=drop chain=input comment="drop dns2" dst-port=53 in-interface=\
    ether1 protocol=tcp
add action=drop chain=input comment="Drop General" in-interface=sfp-sfpplus1
add action=drop chain=input comment="Drop General" in-interface=ether1

/ip route
add distance=1 gateway=192.168.1.1 pref-src=84.54.55.1 routing-mark=SECONDARY
add distance=1 gateway=192.168.10.1 pref-src=84.54.54.1
/ip route rule
add dst-address=0.0.0.0/0 src-address=84.54.55.0/24 table=SECONDARY

There is no further configuration. The rest are scripts, etc.

Thanks.

Please edit the above post and place [code] before the configuration export and [/code] after it.

As I’ve assumed, there is just a single /ip route rule row, so all the traffic from 84.54.55.0/24, including the one towards 84.54.55.0/24 itself and to 84.54.54.0/24, is marked to use WAN2.

So you should modify it the following way:

/ip route rule
add dst-address=84.54.54.0/24 action=lookup table=main
add dst-address=84.54.55.0/24 action=lookup table=main

add dst-address=0.0.0.0/0 src-address=84.54.55.0/24 action=lookup-only-in-table table=SECONDARY

The /ip route rules are processed the same way like firewall rules or ipsec policies, top to bottom until the first match.
The action=lookup-only-in-table prevents the packets from being sent out via WAN1 if WAN2 is down so the route via WAN2 becomes inactive. With plain action=lookup, if no route is found in the required routing table, the packet is routed using the routes in routing table main (i.e. those with no routing-mark).

I don’t modify the routes?

/ip route
add distance=1 gateway=192.168.1.1 pref-src=84.54.55.1 routing-mark=SECONDARY
add distance=1 gateway=192.168.10.1 pref-src=84.54.54.1

Thanks.

There is no need to modify the two default routes. As I wrote before, each time a PPPoE client connects, a route with distance=0 and dst-address matching the assigned IP address of that client is dynamically created in routing table main - use /ip route print to see that.

Out of all routes whose dst-addresses match the destination address of a packet, the one with the most narrow (long) prefix always wins over all the other ones in the same routing table. So since these dynamically added routes exist, packets to their dst-addresses will ignore the default route.

[quote=Normanj post_id=787611 time=1587523665 user_id=161941]
Thanks, Sindy, but how about the multi-subnet can meet each other to connect can’t ping and connect each subnet on my Mikrotik please help thanks in advance..
[/quote]
@Normanj, unless you are an alter ego of @planetamurciano who’s forgotten his password, please create a dedicated topic and edit your previous post with a link to it. And put the configuration export to that topic straight away, from the description it is unclear what your actual issue is.

@sindy, works perfectly.

Thank you! Thank you! Thank you!

:smiley: