-
Notifications
You must be signed in to change notification settings - Fork 752
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
Port forwarding via wireguard interface not working #4389
Comments
same issue on my system |
my 2 cents: its not just port forwarding via WireGuard, its generally all VIP that don't behave like a physical interface. The same problem is with GRE and OpenVPN Tunnels. Last time I researched this I suspected reply-to to be the problem. What I had working was NAT through WireGuard tunnel after hours fiddling around with this. I would like to use a WireGuard Interface with a public ipv4 and run HA proxy or just NAT it but it doesn't work. |
Same issue on the latest 20.7.5. Port forwarding through OpenVPN tunnel in exactly same configuration works just fine, so this is Wireguard specific. |
You can play around with reply-to Rules to figure it out. I dont have a lab to test |
Same issue on WireGuard Port forwarding, in my opinion the problem is in the routes, the traffic does not return for the same input route. |
Correct, there is a mismatch in the reply-to rules somewhere |
Port forwarding works for me on OpenVPN but not WireGuard. |
I am also trying to use wireguard + port forwarding and a public IP from the other endpoint and it is not working. Seems related to routing table. I wrote about it here before I found this bug: https://forum.opnsense.org/index.php?topic=21006.0 |
Any links / references on how to do these test or play around / sample commands etc? |
@TheLinuxGuy don't waste time on it, I tried everything already. pfsense-devel now has wireguard using the kernel implementation, opnsense will probably follow with 21.1.x/21.7 The kernel implementation will boost performance again and hopefully fix the routing problem. |
I'm curious why should it solve routing issues? Kernel WireGuard has everyone giddy, but it won't live up to the hype for sure. |
not sure if this is relevant, but managed to make outbound NAT and port forwarding work on WG after weeks of trial and error the key component missing was WG only works on default WAN IP not WAN VIPs that you may have, and also you need outbound NAT rules for the port forward traffic coming in and going over the tunnel and also manual MSS value set for all to work properly more references here https://forum.opnsense.org/index.php?topic=21445.15 |
This issue has been automatically timed-out (after 180 days of inactivity). For more information about the policies for this repository, If someone wants to step up and work on this issue, |
From the forum discussion port forwarding works with the kernel implementation. The package is based on the freebsd rework by jason and not the horrible netgate implementation. Install with (experimental and still in work): |
Please only install wireguard-kmod instead to avoid future side effects with the wireguard meta package. |
Can still not get this to work, no matter what I try. |
I did a quick test and it indeed still routes over wan. |
I'm also unable to make port forwarding works. This ticket should be reopened, if not I can open a new one. In my case, I installed wireguard-kmod, rebooted. tcpdumps below, you can see packet arriving fine on wg1 but being replied back on wan directly. OpnSense wg1 tcpdump:
OpnSense ix1_vlan34 tcpdump (my WAN interface):
|
It would be better to take this to the forum where people can actually tell you it works and help diagnose. Also, kmod is unsupported at this point. Cheers, |
I noticed this commit 286000d
just tested 21.7.b with the new reply-to option and it looks like WORK |
@amonhk I think this is still not available for general public, right? But when we create a NAT port-forward, the firewall rule is added automatically and associated, and we don't have access to change this. If this makes it to work, the NAT rule should handle the firewall rule automatically as well. |
Already tried that, still does not work: https://forum.opnsense.org/index.php?topic=22856.0 |
Is this a misconfig by all of us, or this is a bug? if it's a bug, or this issue needs to be reopened, or we need to open a new one. |
Since the exact same setup works with openvpn and ipsec I don't see how this is a misconfig from us. Site-to-Site works, it's just port forwarding where replies get routed over wan instead of the wg interface. Disabling reply-to and several other settings have no effect on this. The only workaround is to masquerade on the client side. It would be interesting if pfsense has the same issue though. |
@trunet I also don't understand why the same openvpn logic applied to wireguard doesn't work (I think it's a bug) I hope it will be useful to someone |
Thx for testing, I plan to write an Advanced example section for WG docs |
same port forward rule for both openvpn and wireguard interfaces. for openvpn it adds reply-to automatically, for wireguard it doesn't.
|
pfsense doesn't (or at least didn't previously) have the same issue. I migrated from pfsense not too long after they introduced wireguard (due to the wg implementation drama / pfsense announcing they were going to remove wireguard temporarily) I'm certain I had port forwarding working on wireguard interfaces in pfsense, but I also can't get them working in opnsense. |
I did some $this->log to debug the problem. wireguard interface doesn't contain a gateway on the interfacemapping, although I have a gateway defined on "Single"... openvpn contains a gateway there.
Therefore, https://github.com/opnsense/core/blob/master/src/opnsense/mvc/app/library/OPNsense/Firewall/FilterRule.php#L150 is false and it doesn't add reply-to wireguard interfaces. |
I can confirm that manually creating the NAT port forward firewall rule, including the reply-to, fixed the port forwarding issue via Wireguard! I could not figure out why Transmission kept saying my listening port was closed. It worked via WAN, but stayed closed via the WG interface. I even used Wireshark and could see Transmission communicating back an forth with 87.98.162.88. There was just some traffic that didn't happen when using the WG interface. I'm so lucky I stumbled upon this github issue! |
Important notices
Before you add a new report, we ask you kindly to acknowledge the following:
[x] I have read the contributing guide lines at https://github.com/opnsense/core/blob/master/CONTRIBUTING.md
[x] I have searched the existing issues and I'm convinced that mine is new.
Describe the bug
Port forwarding doesn't work through wireguard interface to lan.
Tip: to validate your setup was working with the previous version, use opnsense-revert (https://docs.opnsense.org/manual/opnsense_tools.html#opnsense-revert)
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Establishing a tcp connection between WAN host (xxx.de) via wireguard interface (wg0) to LAN host.
Screenshots
https://i.imgur.com/x9hBagG.png
https://i.imgur.com/dJs9l38.png
https://i.imgur.com/Ylx9J3L.png
Relevant log files
tcpdump on LAN interface on OPNsense
tcpdump on wg0 interface on OPNsense
SYN ACK doesn't get forwarded
Environment
OPNsense 20.7.3-amd64
Forum Report
https://forum.opnsense.org/index.php?topic=18013
https://forum.opnsense.org/index.php?topic=18062
https://forum.opnsense.org/index.php?topic=19409
https://forum.opnsense.org/index.php?topic=17973
The text was updated successfully, but these errors were encountered: