RouterOS blatantly ignores pref-src. Can this really be a bug?

As described, the side whose configuration was presented has this peer entry, and this address (and the dynamic route it adds):

/interface wireguard
add listen-port=13231 mtu=1420 name=wireguard1
/interface wireguard peers
add allowed-address=192.168.50.0/24 interface=wireguard1 name=peer1 public-key="22SMLvYh7cQzj3/sGFeFLn7l0xVePXM59DLms3qnNUY=" responder=yes

/ip address
add address=192.168.50.2/24 interface=wireguard1

The other side has this:

/interface wireguard
add listen-port=13231 mtu=1420 name=wg-test
/interface wireguard peers
add allowed-address=192.168.50.0/24 endpoint-address=192.168.112.10 endpoint-port=13231 interface=wg-test name=peer4 persistent-keepalive=10s public-key="+XbZ8kxNGw2i6my6hOzSK3Ih2VMH03gjzckpr4+5cj0="

/ip address
add address=192.168.50.1/24 interface=wg-test

Nothing wrong with it and works fine. Both sides can ping each other, transit traffic, etc.

Using a /32 allowed address on one end and a wider subnet on the other is a common config. So is using /32 on both. So is using the same /30 on both.

Absolutely correct. You don’t even have to have a smaller distance for the /32 route - longer prefixes are always preferred, regardless of distance. If you know the peer’s address is advance this is actually fine to do.

For normal services (such as DNS over udp, OpenVPN over udp, etc.) you are correct and the source address is where the request was sent to. Wireguard follows a different architecture, and leaves the source address to be assigned by the initial output routing stage. (It is actually done to allow easy peer roaming.)

My post with the full description:
http://forum.mikrotik.com/t/mangle-policy-based-routing/181586/6
To quote:



Packets don’t carry connection marks (it’s not in the IP packet), they are assigned by conntrack. (There are some exceptions.) The packet output by wireguard has no marks whatsoever on it initially. The packet goes:

[emitted by wg] → initial routing decision → conntrack → mangle output → final routing decision (routing adjustment) → and so on

The packet is annotated with the connection mark in the conntrack phase. Until then, there is no associated connection mark. (On normal linux, wg interfaces have a property fwmark, which allows all packets emitted by wg to be marked on creation - this is not currently available on Mikrotik.)

Again, packets on interfaces (ethernet, virtual interfaces, all of them) come into the router “naked”. Conntrack labels them based on the conntrack entry it associates with them. When a mangle assigns a connection mark, it is noted in the conntrack entry the packets nf metadata references.

Again, dst-nat modifies the conntrack entry. That’s its primary purpose. The translation is done immediately to be in line with the (freshly modified) conntrack entry.

Un-dstnat only changes the address. The interface is decided by routing. In mangle output a routing mark “wan2” is applied based on the connection mark “wg-wan2”, and the output interface is determined in the “routing adjustment” phase based on the routing mark “wan2” to be the wan2 interface.