-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MWAN3 doesn't support correctly WAN based on OpenVPN tun #3486
Comments
Hey etomm, Any chance you could create patch based on your local copy of network.sh, showing your changes please? I'm seeing the same issue, and would like to get things working. |
I really have few time to look into the modifications, but I can try to collect something. Difficultly would be a patch, I did it live on a working LEDE system. I still don't build my LEDE and relay on prebuild firmwares. |
I definitely don't want to cause you work, is there any chance you could paste in network.sh? I'm happy to diff out the, uh, differences :) |
Tried to change network.sh network_get_gateway to this: network_get_gateway() { however, it's not working. is network_get_gateway is supposed to get the gateway or check if gateway belongs to interface? @etomm Any help with this will is appreciated! |
You are right, I completely forgot the issue... too much things to think about. So I opened the network.sh and I modified the network_get_gateway like this:
I added my rows to the ones that were just present... right now I don't remember which one they were. I think from when the _dummydev variable is appearing until the unset ___gateway. Hope this can help both of you. |
@etomm Hey man, thanks for sharing your changes. |
I'm sorry it didn't work for you. That time I remember I debugged the script adding various log messages before catching the failing function was that one. Did you try to do the same? |
Thanks @etomm. I have tried. The problem is the same you were having - empty gateway info. However this fix and others I've tried didn't work. |
Maybe a bit of configuration files would help. Like Network, OpenVPN and MWAN3. But for example to me sound strange that you are doing it in tun0? is it the Device name or the Interface name? |
Hi etomm, would it be possible to post your modified /lib/functions/network.sh somewhere? Say using dropbox link? This way we can try whether your version works for us. The files should not contain any personal info anyway so it should be safe to be posted. |
Here it is http://pastebin.com/3py8Pesc but I still suppose a misconfiguration. |
@etomm I have uninstalled all relevant packages along with all configs. I wasted 2 days on this. |
I believe the package is dead. Try OpenVPN-Policy-Based-Routing. Here: https://forum.lede-project.org/t/openvpn-policy-based-routing-web-ui-testers-needed/1422/156 |
Not quite, but the previous maintainer went MIA. @feckert has been doing mwan3 stuff lately. |
Aside from the issue with |
@nidstigator mwan3 is not tied just to OpenVPN. It is useful for whichever redirection policy and I use it together with ipsets. Maybe we should move the but to the OpenVPN package? |
@nidstigator i am not sure if this is a problem of mwan3. What is the setup and configuration? |
@hnyman @jscinoz I apologise if I was misleading, I didn't mean to. @feckert I gave up a long time ago on using mwan3 for my split tunnelling setup, and have been using OpenVPN-Policy-Based-Routing. mwan3 doesn't recognise that tun interfaces are up/down. I am happy with my current setup and don't need to use mwan3 anymore. But thanks for asking. @etomm I agree, that was an oversight on my part. Mwan3 isn't the same as OPBR. |
@feckert almost sure it is a problem of OpenVPN that doesn't fill ubus informations correctly. I don't know if it should be solved OpenVPN side or MWAN3 side. With my modified scripts I bypassed the problem, but I don't think it is the right solution. Maybe the maintainer of OpenVPN should look at this. |
Related: openwrt/openwrt#220 |
After a bit of investigation, I've come to the same conclusion as @etomm - this issue is due to the network.interface information for OpenVPN interfaces (well, tun interfaces in general) not being populated correctly. There's an outstanding question here as to the expected behaviour however: Should netifd be populating this information automatically whenever an IP address change occurs on an interface (regardless of type)
This can be done at a user-level with a custom script for OpenVPN's --up option, but it would be nicer to have this properly integrated. I imagine the simplest way to do this is to amend the OpenVPN init script to include the appropriate --up and --down options in the generated OpenVPN config file. We would also need to figure out how to do this while still supporting user-provided --up/--down scripts - perhaps simply passing through the configured path to the user's custom scripts and invoking these at the end of the netifd-integration up/down script. |
i just want to report that replacing
relevent Output of "cat /etc/config/network":
not sure how much of the following is necessary, but here it is anyway: i have added this to the
now
Checking ip rules: (before replacement it failed)
Checking routing tables still fails:
but routing through vpn works fine (yay!) also make sure to place your VPN rule above the default rule. THANKS :) |
Do you guys know if this issue is fixed in LEDE trunk? Also, is this a related issue? #3110 |
It is not fixed in LEDE trunk as far as I am aware. There is a PR at lede-project/source#1103 which integrates OpenVPN into the the
|
Yes mine is quite old at this time and unfortunately I didn't think at
making a patch version those days... I was doing it overnight!
Good job!
…On Oct 18, 2017 00:26, "rhunwicks" ***@***.***> wrote:
It is not fixed in LEDE trunk as far as I am aware. There is a PR at
lede-project/source#1103
<lede-project/source#1103> which integrates
OpenVPN into the the netifd subsystem. That is probably the correct
approach. But I tried using those netifd files with 17.01.3 and they
didn't work, so I hacked /etc/functions/network.sh as described above.
@etomm <https://github.com/etomm> 's version didn't work as-is but based
on it I have a working version for 17.01.3 that involves changing
network_get_gateway and network_get_ipaddr. It doesn't aim to be
comprehensive - merely sufficient to get mwan3 working with openvpn:
--- /lib/functions/network.sh.orig 2017-10-17 22:12:18.000000000 +0000
+++ /lib/functions/network.sh 2017-10-17 22:24:11.000000000 +0000
@@ -23,6 +23,18 @@
# 2: interface
network_get_ipaddr() {
__network_ifstatus "$1" "$2" "['ipv4-address'][0].address";
+
+ network_get_physdev ___dummydev "$2"
+
+ [ -z "$___dummydev" ] && return 1
+ ___ipaddr=`ip addr show $___dummydev | grep inet | awk -F'inet | peer' '{printf $2}'`
+ unset ___dummydev
+
+ [ -z "$___ipaddr" ] && return 1
+ eval "$1=$___ipaddr"
+ unset ___ipaddr
+
+ return 0
}
# determine first IPv6 address of given logical interface
@@ -191,6 +203,18 @@
[ "$3" = 1 -o "$3" = "true" ] && \
__network_ifstatus "$1" "$2" ***@***.***='0.0.0.0' && ***@***.***.nexthop" "" 1
+
+ network_get_physdev ___dummydev "$2"
+
+ [ -z "$___dummydev" ] && return 1
+ ___gateway=`ip addr show $___dummydev | grep peer | awk -F'peer |/' '{printf $2}'`
+ unset ___dummydev
+
+ [ -z "$___gateway" ] && return 1
+ eval "$1=$___gateway"
+ unset ___gateway
+
+ return 0
}
# determine IPv6 gateway of given logical interface
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3486 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AF05vyrQpDjr3A0jihSics_KawGU6UOkks5stSmwgaJpZM4Kq4FZ>
.
|
I just upgraded to LEDE 17.01.4 from OpenWRT Chaos Calmer 15.05.1. Previously I used mwan3 to selectively route traffic over OpenVPN and now it no longer works. I debugged it to the point of determining that it doesn't even start mwan3track for the tun interface, then found this bug. I installed the above patch quite easily, but it doesn't help. "ubus call network.interface dump" has no IP info for the tun interface, which I assume is part of the problem. Any ideas? 17.01.3 and 17.01.4 network.sh seem the same, so I'm at a loss. |
Have a look here.
https://forum.lede-project.org/t/openvpn-policy-based-routing-web-ui-testers-needed/1422
It replaces the need of using mwan3 for openvpn routing.
…On Mon, Oct 23, 2017 at 4:09 PM, mfullerca ***@***.***> wrote:
I just upgraded to LEDE 17.01.4 from OpenWRT Chaos Calmer 15.05.1.
Previously I used mwan3 to selectively route traffic over OpenVPN and now
it no longer works. I debugged it to the point of determining that it
doesn't even start mwan3track for the tun interface, then found this bug.
I installed the above patch quite easily, but it doesn't help. "ubus call
network.interface dump" has no IP info for the tun interface, which I
assume is part of the problem. Any ideas? 17.01.3 and 17.01.4 network.sh
seem the same, so I'm at a loss.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3486 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AElYeu5GYm9MpU7-yxtsWztvmrdmvdkhks5svKwNgaJpZM4Kq4FZ>
.
|
@mfullerca the patch doesn't fix
|
@mfullerca if you have already applied @rhunwicks's patch you might try calling i have that executed in my vpn up script |
@rhunwicks thanks! Interesting: $ip is set but $gw is not. netstat -re shows that the corresponding tun interface has correct gateway entries, and the default has the metric mwan3 expects. |
@mfullerca can you post your whole /lib/functions/network.sh to a pastebin somewhere and link it here. |
@rhunwicks https://pastebin.com/M3GLj9Db Btw I just rebooted to verify that there was no weirdness as I'd been changing many things before I made my last post and still $ip is set but $gw is not. I should also add I found a work-around, albeit a poor one: if I change the tun interface from "Unmanaged" to "Static" and assign it the values it is already getting when the VPN connection is established, then it works. |
@rhunwicks also here's the results of running your debugging script under "sh -x": https://pastebin.com/PWnMwgmJ |
@mfullerca what's the result of |
@rhunwicks (btw sorry to take so long, had to find a good time to revert the work-around):
|
Hi, I'm trying to (maybe partially) fix it #5033 . Please take a look at it. |
@mfullerca that |
@rhunwicks I'm not sure offhand what you're looking for (sorry, I was a sysadmin 1987-2001 so my networking skills are a bit dated). There is a default route for that interface:
That route comes from /etc/config/openvpn via the client-side option:
AFAIK there's only two other options with OpenVPN:
|
@mfullerca I'm not a sysadmin at all, so I probably can't be any more help, other than to say that my
where I think that and my
The workaround I added to |
I've seen one interesting line in packages/net/mwan3/files/lib/mwan3/mwan3.sh Line 240 in d971514
I doubt it is unnecessary since it can be simply -A mwan3_iface_out_$1 -o $interface -j MARK --set-xmark $(mwan3_id2mask id MMX_MASK)/$MMX_MASK IIRC. If that is true then mwan3 can remove one dependency on ubus. |
@rhunwicks I didn't know about the vpn_gateway keyword, but otherwise believe my config is the same as yours except that I hardcoded the gateway IP. I changed to the vpn_gateway keyword and nothing changed in output or behaviour (except my config is now robust to changes in addressing at the server end). I diffed your output and mine and noticed that basically yours says:
whereas mine says:
Otherwise they are pretty much the same. Sadly documentation on the meaning of the output of various commands is lacking, but I hypothesized a difference in OpenVPN network topology. I own the server on the other end, so I changed |
seems to be fixed - let's close this epic ticket. |
MWAN3 is not able to recognize when a OpenVPN based “wan interface” is online or not. This is due to the fact that lib/functions/network.sh network_get_gateway uses ubus to collect the gateway information and in case of openvpn ubus return a perfectly emtpy result. I modified the network_get_gateway function to use "ip addr, grep and awk" and it began to work.
This is not the case with CC 15.05 that was having a really more simple hotplug script for mwan3.
All the tests are being done on LEDE trunk on a Linksys EA8500. Before, in OpenWRT CC 15.05 on a Archer C7 everything was working correctly.
The text was updated successfully, but these errors were encountered: