How do I set source-IP?

BGP on v6.49.5

I’m having an issue that my router is using non-routed IPs for the IP source..

The public bandwidth test server for example Public-Mikrotik-Bandwidth-Test-Server(s) ( now shutdown as of April 1st 2025 ) is reachable via an IX, so non-routed IP on the interface.. The bandwidth test doesn’t have a source-IP field.

My home ISP is similar. Traceroute and Ping to my home doesn’t work unless I put in a source IP or alternate interface..

Is there a way to set pref-src on dynamic (BGP) routes?

According to the :routing filter documentation [1] it looks like you can use the :routing filter set set-pref-src=<ip_address> option in inbound filters.

[1] https://wiki.mikrotik.com/wiki/Manual:Routing/Routing_filters

Thank you!

That is not where I was expecting. Cool

Sure thing. I’m curious what your use case is that requires it. :smiley:

By default RouterOS is trying to use the IP on the interface closest to the destination for it’s output traffic, for exchanges, it is using the exchange IP, which can’t be replied to because they are not routed.

For example, the bandwidth test server to my router is through a peering exchange, not transit, so inaccessible.

For a lot of “/tool fetch” downloads to work, I need to add source-ip= to the command for anything available via an exchange.

Confirmed fixed. :slight_smile: :slight_smile:

Ahh, makes sense. You did mention that this was in an IX setting and I didn’t fully think through the ramifications of peering with unroutable address space. Thanks for the clarification.

Using pref-src / “Pref. Source” / “Preferred Source” on route without involving consuming firewall rules???

I did try those first..

This solution doesn’t work for IPv6 though.. Opened a bug-report today.

I suppose IPv4, because I do not see any about IPv6

yeah for some people they seem to prefer ipv6, hopefully no one forces it down our throats… like recycling :stuck_out_tongue_winking_eye:

So the bug isn’t a bug because they never designed it to work for IPv6, but this is needed for the same reasons it is needed for IPv4..

Not working as documented seems like a bug to me..

Overall though, this breaks other features and functions,

System - Packages - Check for updates

being one of them.. Can’t use dual-stack services that connect through an internet exchange, because IPv6 is preferred over IPv4..

Argh..

As in, the preferred-source field of IPv6 routes simply doesn’t work? I haven’t had a reason to try and set it and I want to make sure I’m understanding what you ran into.

Exactly. It gives an error when trying to enter an IPv6 address.

Edit: Specifically the set-pref-src in BGP route filters, discussed above.. I don’t know (or care) about for static routes.

If Mikrotik claims this isn’t a bug, that is disappointing.

I will admit that source address selection in IPv6 is significantly more complicated (multiple scopes and dynamic prefixes with different lifetimes) but for a device acting as a router, you need to be able to have the flexibility to pick your source address. I have a similar complaint over here [1] where OSPFv3 seems to pick an address at random to include in the routing table for virtual links but doesn’t give you the control to pick one.

[1] http://forum.mikrotik.com/t/ospfv3-type-9-lsa-behavior-and-extra-128s/157032/4

Have you found a solution to your problem in the meantime? I am in a similar situation. I can set the pref-src for IPv6, but it still uses a different source address.