WireGuard Peers: allowed-address conflicts other peers

Hello!
I have a brand new problem with the Mikrotik's WireGuard server implementation.
I don't know from when, but after the latest updates of RouterOS, settings the allowed-address field of the peers configuration with 0.0.0.0/0 or ::/0 gives the allowed-address conflicts other peers error.

Regardless of the fact that this approach has always worked in the past, I find myself in the situation of not knowing how to fill in that field, because I actually have no idea what IP addresses the client will use to make the connection, given that in most cases these are cellular network connections.

In this case, what approach should be used? Is there another way to indicate that the address the connection will come from is unknown?

Thank you!

The allowed addresses are the internal IP addresses allowed through inside the link. These are usually Private IP addresses. In a client/server setup for the Server the allowed addresses is commonly the single fixed IP address assigned to the client's WireGuard interface

Having overlapping IP addresses on different peers (for the same WireGuard interface) has never and can't work reliably. (0.0.0.0/0 is the ultimate overlapping IP) RouterOS Complaining about it seems new though.

changelogs 7.25 stable: *) wireguard - warn when an allowed-address overlaps another peer;

So I just guess if another WG instance could be used for the "road warrior"...

No, this is what appears in Current Endpoint Address and has no relation to allowed-address. allowed-address only cares about the addresses inside the tunnel, not the address of the wrapper UDP packets that transport the WG data. That your clients use cellular networks only causes the source/destination of those UDP packets to change. Inside the tunnel the peers should have fixed addresses. and the packets inside the tunnel have addresses not related to the cellular address.

What allowed-address controls:

  • When the remote peer (for example your mobile phone) establishes the WG connection (with handshake) and start sending packets inside the tunnel to the other side that is the router, the source address of those packets inside the tunnel will be checked against the list of allowed-address associated with that remote peer. If there is no match (including subnet check when you use shorter prefix lengths like /0 or /24, /64, etc....) the packet (that arrives inside the tunnel) are dropped.

  • When a packet needs to be sent or forwarded (for example from a LAN device) by the router, and the best route (from /ip route or /ipv6 route) for the destination of the packets dictate that the WireGuard interface is to be used as the gateway, the packet to be sent will be handled by the WireGuard interface. WG will look at the list of peers belonging to that WireGuard interface and check the allowed-address field of those peers, the first peer with the best matching allowed-address will be chosen, and the packet will be sent through the tunnel established with that remote peer.

That why there was plenty of threads in the past, were people were unable to have more than one remote WG peers working at the same time. They might create 2 peers associated with the same interface, then give one allowed-address=10.12.34.56/24 and the other allowed-address=10.12.34.67/24 and then wonder why communication with 10.12.34.56 doesn't work at all. Because both 10.12.34.56/24 and 10.12.34.67/24 have the same result as 10.12.34.0/24 when matching with 10.12.34.56, it happened that the peer with allowed-address=10.12.34.67/24 is picked to receive the packet, instead of the one with allowed-address=10.12.34.56/24. But back then if you edit and save the allowed-address=10.12.34.56/24 it will raise in the lookup order and might be picked again. So you have people saying a peer only works if they disabled and re-enabled it. But stops working when they edit other peers.

To prevent that, recent RouterOS version introduced the error and warning messages:

  • If two or more peers have one (or more) exact same subnet in allowed-address, such as the situation above when one has allowed-address=10.12.34.56/24 and one allowed-address=10.12.34.67/24, which are both allowed-address=10.12.34.0/24, that's an error and you won't be able to save the change, (you see the error message if the peers were already created previously in older versions). Same when both have allowed-address=10.12.34.56/32 for example.

  • If the subnet are not the same but overlap, for example one has 10.12.34.56/32 and one has 10.12.34.0/24, or one has 0.0.0.0/0, they overlap, but will not produce an error. The range with the shorter prefix (/24 or /0 in the example does contain (which also overlaps) the address with the /32. But it still work because the routing inside WG does honor the priority set by the prefix length. The longer prefix (more precise) will be chosen first if they match.

    So with 3 peers, one with allowed-address=10.12.34.56/32, one with allowed-address=10.12.34.0/24, and one with allowed-address=0.0.0.0/0 attached to the same WG interface, a packets destined for 10.12.34.56 will reliably use the 1st peer as destination. And a packet with destination 10.12.35.67 will use the peer with allowed-address=10.12.34.0/24. One with destination 8.8.8.8 will use the 0.0.0.0/0 peer.

    So there is no ambiguity, it works that's why you can still save the change and the message is only a warning not a true error message. It's still a warning because normally you probably wanted two /32 peers instead of two overlapping /32 and /24 peers.

But if put allowed-address=0.0.0.0/0 on every peer of the same WG interface then of course it's a big fat error situation.

Normally you only use allowed-address=0.0.0.0/0 (and / or ::/0 for IPv6) for at most one peer per interface, and that's most of the time for the case when you have to route internet traffic through the tunnel (browse Internet via remote WG VPN), in those case the packets to be sent / received have all possible IP addresses and can only be filtered by 0.0.0.0/0 or ::/0.

Hello!
As usual, thank you for the explanation, now I understand where to look for the options.

Now I see the differences between local and remote addresses, and allowed networks.

Of course I made a mess trying to following a tutorial on an old version of the documentation.

Tahnk you!

I have another silly question: I have to put the WireGuard interface in some Interface list? Like the LAN one? Or is it better to leave it outside?

Thank you again!

If it's for remote access "as if you were on the LAN", then it's totally fine to put the wg interface in the LAN interface list. So yes.

The only situation where you would not is when you want different access rules for someone connecting through wg.

BTW current Manual contains detailed description of parameters, but only when version 7.24 is selected. For versions 7.25 and 7.26 the parameter reference is no longer available...

You could try assigning each WireGuard peer a unique IP address or subnet instead of using 0.0.0.0/0. The client’s public IP can change on cellular networks, but the WireGuard tunnel IP should remain unique for each peer.

If the WireGuard interface is intended to accept connection from your remote devices like phones and laptops, to allow those devices to access your local resources, or to manage the router, then, as @lurker888 wrote, usually you can put the WG interface in the LAN interface list, especially if you use the default MikroTik firewall (defconf). Because in the default configuration some access like managing the router, or talk to other device through IPv6 is only allowed with the LAN interface list.

But if you create the WireGuard interface because you bought some 3rd party VPN service, and intend use WG to connect to them and direct part of your internet traffic through that VPN, then that interface should be put in the WAN list instead, if you use the defconf firewall configuration. Not only does it automatically apply masquerade to the outgoing connection, but the firewall also prevents incoming connections from the internet, through that 3rd party VPN service, to your router. The WG peer on the other side should be considered as hostile as the internet.

That's because MikroTik has continued to migrate the parameter definitions to the CLI Reference section of the manual. So in the current documentation for version 7.26 the descriptions are now located here:

peers | RouterOS Manual

The links to the relevant CLI reference sections are usually at the top of the page:

Thanks. I have missed it as the hierarchy of the CLI somehow differs from Winbox GUI....it will take me a while to digest. ZeroTier and WireGuard has been placed under VPN section in docs, but in the CLI the ZeroTier is directly mentioned while WireGuard is a sub-chapter.... so the muscle-memory has some effect.

Have a nice day!

Good night, but why did they break the WireGuard logic starting from 7.25? Now there are some address conflicts in the peers that weren't there before. Because of this, you can't update properly to firmware newer than 7.24.x, and even more so to 7.26 to get RPS.

For a long time I've used Wireguard with multiple peers and designated subnets on Allowed-address list
On top of this, one of peers was configured to accept also 0.0.0.0/0 on top of list of subnets.

Why that way?
Configuration visibility, allowed-list listed all subnets by default behind that peer and allowed any too.

What has been routed through this was controlled by routing table, effectively only one client was pushed through that as default routing.

With new firmware 7.25 pushed as emergency due to latest Linux Kernel issue, I've been caught in situation that peer tunnel was not brought up after upgrade and a local, remote hands had to be used as the device is remote for me.

Ask and suggestion:

  • breaking changes should have an opt-in flag (yes, there was potentially some mention of it in Release Notes, but hey - who really reads and checks real impact of each line in the Release Notes?)
  • can we have allowed-list overlap as not enforced unless a config flag is checked? (which can be default for new deployments and disabled for old pre-enforced versions)

This might be now treated as RFE though in fact is a bug as brought down my tunnel and created a more serious outage.

It would be appreciated if it could be considered by the Mikrotik team.

Sharing it here for others to see and potentially chime in.

Please post the non-working peer list export.

I really don't mean to be rude, but I have doubts about what you describe. As described here 7.25.1 [stable] is released! - #72 by lurker888 things seem to be working well according to both my and others' tests.

By working well I mean that overlapping but different prefix routes are accepted and installed correctly. It's only exactly matching (including prefix length) routes that are rejected.

Are you sure that you only had one peer with a default selector?

At the minute they also match against disabled peers (hopefully this will change), so if you have a lot of disabled cruft it can hurt.

Wireguard implementation continues to evolve thats the good news.........

To the ops questions: CGGX provided excellent answers!
For a small bite and swallow beginner approach though.....:

As noted its important to distinguish between using your own router or cloud or perhaps friends, own internal wireguard network and a third party VPN (when simply using wireguard as the medium to access the internet through another provider).

For own Wireguard Network:

Allowed IPs either,
(1) IDENTIFIES expected private IP addresses coming to your router from the tunnel

  • usually only the incoming assigned wireguard IP to a device, like a laptop, ipad, iphone etc...
    OR
    -the assigned wireguard IP + incoming external private IP addresses ( usually when connecting to another router).

(2) IDENTIFIES, the private IPs you wish to allow local users to access (typically at another router).

What should be clear, in the case of private subnet IPs coming in, or being reached (at another router), is that they are NOT local and thus will require their own routing like so........
/ip route
add dst-address=192.168.50.0/24 gateway=my-wireguard-interface-name routing-table=main
comment="Wireguard access for bobs router to use my internet, or access my Lan network XXX"

The advantage of making wireguard part of the LAN interface list, is that incoming remote users, due to default firewall rules, have access to DNS and the internet through your router. Other access, via input chain and forward chain firewall rules, delineate what else remote users have access too. ( Typically the admin to the input chain and to all LAN subnets, while others should only have access to one or more LAN subnets as required.

++++++++++++++++++++++++++++++++++++++++++++++

Note1: All your users devices, on the other hand can have 0.0.0.0/0 set in their wireguard allowed IPs......and this is very common and mandatory for internet access. This by ispo facto also includes any private subnets you may have on the destination router, which as stated you control allow or not, via firewall rules.

Note2: Use of 0.0.0.0/0 on any router is problematic when you have more than one client listed on the SAME WIREGUARD INTERFACE. Because 0.0.0.0/0 means all possible addresses, this listing becomes a hog for all internal Wireguard routing and firewall type processes for that wireguard interface.

ex1. traffic comes in from a remote user to the router, if a client's allowed IPs on the router state 0.0.0.0/0, that setting captures all input for that wireguard interface and thus will match all incoming cases, regardless of the actual incoming client
ex2. local traffic is headed to a remote private subnet, if a client's allowed IPs on the router state 0.0.0.0/0, that setting captures all outgoing addresses and thus the traffic will go to the associated client device, regardless of other clients on the list

Rule of thumb: 0.0.0.0/0 should not be used on a router, unless its the only client in play (like third party VPN).

Lesson Learned: I thought that the router looked at the list of clients per interface as an ordered thing and one could get fancy and put 0.0.0.0 at the bottom, to work-around the issue, but discovered that its more of a random type thing, or at least based on last connection vice any specific ordered list.

Work around: If one needs 0.0.0.0/0 from a client, create a separate wireguard interface.

@lurker888 , it's all good question and I appreciate your interest to understand situation.
To simplify the list and highlight the problem.
The allow list contained:
Peer A - 192.168.245.2/32, 192.168.0.0/24, 192.168.10.0/24, 0.0.0.0/0
Peer B - 192.168.245.3/32, 192.168.100.0/24, 192.168.110.0/24

Note, the 0.0.0.0/0 as for one of the local IPs, all traffic is expected to be routed via Peer A.

This worked as noted on the earlier versions, for a long time, v6 included.

The moment firmware was bumped to v7.25 - I lost remote access as the peer was shut down, disabled after upgrade. Yes, the upgrade was one remotely.

Architecturally, wireguard peer-list should execute what it gets and any logic of overlap and how routing is done should lie at routing level.
Imagine, there could be different bridges/vrfs with even overlapping destinations subnets (not even talking about different default gateways used, or maybe load balancing across two links).

Whilst I appreciate MikroTik team stepping up and trying to help home users, building an additional intelligence, a silent disablement of a peer is a big no, no.

I hope that one of large customers, i.e. the hotel chain, doesn't lose access after firmware version and MikroTik's are used across hotels (thumbs up to the Sales and Sales Engineering team).

The config that you show should result in a warning, i.e. with only an informational message. Nothing should be disabled. If it is, that's a bug. (Clearly bugs shouldn't happen, and are not good, my point is only that if this is the case, it's probably just someone messing up, not an intentional change.)

v6 doesn't have wireguard.

Wireguard adds an additional routing (or routing-like) layer. Allowed-ip is both used as a filter (what's allowed from a given peer) and a route selector (given the destination address, on this particular wg interface, which peer should I send this to.) I meant routing in this sense.

See my explanation above. It answers your questions.
It would not have worked before due to as lurker states, how the wireguard protocol, vettes incoming traffic like a firewall and now it matches and vettes outgoing traffic like firewall and routing.

In your case, when traffic is incoming, it knows the correct wireguard interface to use for the traffic ( external connection tracking port used etc. ). Then it looks for any matching incoming private Source IPs, to figure out the correct client. Regardless if the traffic is from peer B, aka 192.168.100.X for example, the router could see the 0.0.0.0/0 as a match and then assume the traffic is from peer A.
Depending upon firewall rules, the traffic could be allowed in and the return traffic go out but now to the wrong peer and would be never seen. Hopefully the firewall rules would state, whatever IP came in on peer A, under the disguise of 0.0.0.0/0 would be rejected by firewall rules and never reach the destination on the LAN.

On the flip side, lets say you had a local user that wanted to visit Peer B subnet 192.168.110.Y device. It is very possible that the router would match that request to 0.0.0.0/0 instead and the traffic would go be routed out peer A and be promptly blocked at the other end, if not permitted at the far end.

It is possible for it to have worked before as the connectivity through 0.0.0.0/0 seems as if its random or if not, then partially based upon the latest connections made, vice any logic we put down. I had thought it was by order of peers listed, but that has proved to be also false.

Why do you want 0.0.0.0/0 in the list of peers from another router is the question I have to ask and what make/model is the other router????
( By the way I hope you can see that putting 0.0.0.0/0 down with a list of other allowed IPs, is ridonkulous as 0.0.0.0/0 already includes all the other IPs you put down )

The answers will determine the next course of action................