-
Notifications
You must be signed in to change notification settings - Fork 110
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
Support for Hairpinning #53
Comments
Because it came up recently on twitter, here are a few additional notes:
I suppose the next step would be prototyping some nft rules that do what Dave outlined in the twitter thread. |
More insight from Dave: https://twitter.com/dave_universetf/status/1298100264927289349 I guess we just wait another few days until he explains how things ought to really work in Linux :) |
This comes up as 2nd hit when googling for nftables hairpinning, so I thought I share my experience. I'm not running router7 though. For hairpinning NAT of a portforward from e.g. TCP port 16085 on the outer interface $out_if (using the address $out_ip) to local 192.168.122.2:22 on $lan_if (with the $lan_net IP range), you need to add
And, if you want to make local connections from the router to the service work:
The rules might be a bit narrow, but I go down the careful route (pun intended) with this to avoid accidental NATting. |
The forward filter rules can apparently be replaced by one universal Same goes for the postrouting NAT rules - one |
Here's a full ruleset, configured as above but reduced to a handful of rules by using a map of port forwards (requires nftables >= 0.9.4). https://gist.github.com/neingeist/c97b488f2511bb5ca07c8a07213eccbe |
Thanks for sharing this! I’m pretty busy the next few days, but will take a closer look and try it out next week hopefully :) |
There's no rush ;) |
Yeah, on router7 indeed only 2 modifications are needed: the
I think we can express the rule without using hard-coded addresses (which means they would need to change whenever the public IP address changes) by using Unfortunately, the router7 kernel is built without |
Yep, as expected, these rules work, too:
Next up is changing the router7 netconfig to apply these rules. |
Nice, I didn't know about that one! |
I noticed that I'm unable to connect to a server inside my local network using the router7 public IP and the forwarded port.
Example
Local machine: 192.168.0.100
Public IP: 12.34.56.78
Port forwarding rule: :22 -> 192.168.0.100:22
Result: connection refused
Connecting from outside of router7 works perfectly fine.
To ensure we can connect from the local network using the public IP, it would be nice if support for Hairpinning (see Hairpinning and Hairpin-NAT) could be added. This could be achieved by adding additional nftables rules.
(thanks for @stapelberg for helping me investigating this issue)
The text was updated successfully, but these errors were encountered: