Considering the recent fiasco where the change of date format broke script compatibility we want to minimize script use in production environments whenever possible.
And the sad thing is, the date format could have been easily fixed without breaking script compatibility. This ‘small’ oversight makes the implementation seem… exceptionally well-thought-out.
Could improvements be made, sure!
Can we implement working configs now, yes!
+++++++++++++++++++++++++++++++++++++++++++++
Yep, that sounds about right! The whole exercise has currently resulted in two different issues: No they have not.There is nothing new in this discussionand the first item is the lack of understanding how routing is accomplished on the router and how it is accomplished within wireguard.
Q1. Why are WireGuard handshake responses sent through default gateway rather than the originating interface?
My initial research indicates this is a known issue with some proposed fixes already sent upstreams to the WireGuard devs. Additionally, there are some workarounds that help the connection tracker with proper routing. I’ll get back when something interesting pops up.
Q2_. Is there a convenient workaround for the above issue that doesn’t rely on a DHCP script when multiple WAN interfaces with dynamic IP addresses are used as WireGuard responders? Well, currently this seems pretty difficult since ROS route control is purely based on static IP addresses rather than the logical interface names that are available in the kernel (e.g. “ip rule add from DEVICE table table-name”). However, I’ve got an idea that I haven’t had the chance to test yet._
This issue has nothing to do with wireguard, and its disengenuous to imply so. Its an obstacle to any service be it on the router or on the LAN, if you dont understand how MT routing works.
As to the DHCP item, not MTs issue that some providers dont auto update their gateway IP upon renewing a lease.
I have plain cable, the client updates automatically both the IP DHCP client located paramaters and all my manual routes… How > F knows!!!
My fiber connection does not, hence I have an IP DHCP script for that.
Also one can use interface name for certain dynamic connections like my cable above and also pppoe.
Geez, a little harsh… @Larsa has something working — his problem is clear: “we want to minimize script use in production environments whenever possible”.
It’s not a “lack of understanding”. May not agree with problem, or think it foolhardy – but no need to post just to attack.
I disagree, he inventing a problem thats not a problem. There are working solutions.
Add to the list the million of suggestions to make life easier for users…
While you all mull it over obsessively, I will continue to help others and stop by once in a while, to refute anything stated that is bogus.
The main route table can deal with interface as gateway… Perhaps add’l IPs in-between WG and WAN that use recursive routes and masquerade rules… e.g re-route WG through the main routing table (which interface-based gateways are supported) using a “fake WAN” address?
I made a new bridge, added an IP address to it, put a dst-nat rule for the wireguard traffic to listen on a different port,
and forward to the new IP address, and correct wireguard port.
Then routing rule to route from new IP address to wan via correct table.
Any route that we have in route table except 0.0.0.0/0 gets routed via main.
Then 0.0.0.0/0 can be handled specially.
Saves having to list all the local subnets in your routing rules, yay.
Edit: Maybe not, still need interface next hop address
@Anav - I’m biding my time by exploring possible alternatives since I have no need for quick fixes. Meanwhile, I do appreciate and rely on your tireless effort to make life easier for the users in this forum! @Amm0: You read my mind! I was thinking of testing that along with some variations of nat/masq if I get some spare time this weekend. @rplant: yeah, that’s about what I had in mind. We’ll see what I manage to do over the weekend.
I’m blushing!!
In the meantime, you should help the dude in this thread, he has issues with fastrack and queues. http://forum.mikrotik.com/t/fasttrack-cannot-bypass-simple-queue/174267/1
Why dont you come up with a way to solve that issue... I mean it should just work without any need for additional steps…
Not sure what MT is thinking by making it so hard to add queues…
Cannot wait to see what contortionist solutions you come up with… I am hoping to be blown away by your innovation!!
I didn’t mean to attack-the-attacker either. @anav you do good work here. Just solving some of these “non-problems” is what sometimes eventually yields to simpler “pathways to success”. But always a lot of complaining and arguing before that.
I did that because I didn’t want to have more script update rules to track specific subnet, or have to manually update when a new subnet is added. Clearly never thought about “min-prefix=0”.
Yeah I’m not sure exactly HOW… but somehow “lying” to WG may be the solution to avoid a script.
What kinda annoying here is in V6 the old “dynamic-in” routing filter could have modified the DHCP client added routes, including next-hop, with CONFIG:
dynamic-in - predefined filter chain for all other dynamic routes, i.e. all dynamic routes except (1) those added by routing protocols and (2) connected routes. In this category falls routes added by some external program, for example PPP daemon.
Despite name “filter”, there were various set-XXX operators since it was BGP thing (although did NOT require BGP being enabled). I could use set-check-gateway=ping on /routing/filter in V6 — without a script. Feature was lost with the new V7 BGP engine.
Nothing to do with WG. It’s about how to keep the routing rules “readable” for multiwan.
Say the main route table has some typical multiwan failover setup: WAN1 and WAN2. And have 2 route tables for them and the FW marking. You also have some VLANs and bridging etc. per @anav/@pcunite. No PCC (or ECMP), just failover.
Now you have some device on some VLAN that you want use only WAN2, and not follow “main” distance= failover. Starting with no rules, you can’t just say /routing/rule add dst-address=0.0.0.0/0 src-address=10.10.10.10 table=WAN2
as that will do as it says, and NOT use “main” even for local LANs. Only the main routing tables know about connected route to other VLAN/interfaces. So need SOME rule before that identifies the local LAN subnets that has a table=main…
One way to add “if local LAN, use main” rule is to just add a more specific dst-address= rule for each subnet your using BEFORE the rules to control WAN selection (e.g. dst-address=0.0.0.0/0 ones). /routing/rule add dst-address=10.10.10.0/24 table=main /routing/rule add dst-address=10.20.20.0/24 table=main
And this totally works.
But as the number of subnets, and # of routers, add up… maintaining the routing rules with any new VLAN gets to be a PITA. But needed since /routing/rule is so handy for send specific IP/subnet out a WAN. Since /routing/rules ONLY deal with IP/subnet (thus @Larsa’s feature request for an interface= matcher in /routing/rule), the approach I came up with just saying any private address go to main BEFORE any specific rule for outbound WAN traffic – the three rules above.
But @rplant is more cleaver, since it’s one rule to be place first:
Just to finish from @anav POV. You can also do any inter-VLAN/etc blocking in /routing/rule’s BEFORE the “min-prefix=0 table=main” rule to based on those IP. e.g. action=drop or action=unreachable. As alternative to doing it in firewall…
e.g. In order:
Any drops rules…
Send local traffic to main rule (@rplant way, “all private IP”, or specific subnets)
Okay so that is clear to understand.
I have run across this already and solved it by ensuring the subnets were designed with this in mind before config.
If you have all your subnets in 192.168.0.0 to 192.168.15.0 range, you could simply do
However I like this seemingly elegant approach with apparently no downsides! /routing rule add action=lookup-only-in-table min-prefix=0 table=main
Based on the MT Docs → table for routing rules… min-prefix (integer [0..4294967295]) Equivalent to Linux IP rule suppress_prefixlength . For example to suppress the default route in the routing decision set the value to 0.
All good and well, but what is a min-prefix. what does it describe and how does using 0, somehow state send to all private IP addresses?
( as an aside, I would personally refrain from using routing rules as a substitute for FW rules, they should be used for routing purposes and ONLY used for other purposes if regular FW dont work ).
I would guess that it would be a (global) variable that is set to either yes or no to enable or disable all the routing rules in a single quick, swift, move.
Now you see them rules, now you don’t see 'em anymore.
That was just a typo. I just cut-and-paste from default configuration files, with a bunch of variables at top. My bad. e.g. If there is no multiwan, I don’t want any rules enabled. So imagine some variable at top of config:
:global norules “no”
So when going to setup a router, there are a few variable at top of defconf script that can be tweaked before /system/reset-configuration file=.
And to that point, when you try to have a generic defconf script usable to setup multiple routers… you do start looking “tricks” to keep the config customizations minimal without large :if (routerA) do={}.
Only place I’d worry a bit is with recursive routes — there is the canary 8.8.8.8/32 (or similar) in between. Should work since that’s internal to routing… but testing always good.