Allow source NAT to use interface networks#9220
Open
stevekerrison wants to merge 2 commits intoopnsense:masterfrom
Open
Allow source NAT to use interface networks#9220stevekerrison wants to merge 2 commits intoopnsense:masterfrom
stevekerrison wants to merge 2 commits intoopnsense:masterfrom
Conversation
The old interface only lists interface addesses, not nets, and the rule parser parser only looks for interface names suffixed by "ip". In pf, interface address is used dynamically by being surrounded by parenthesis and includes the ":0" modifier to exclude aliases. By combining this with the ":network" modifier, source nat can also use an interface's network, dynamically, i.e. "($iface:network:0)". This is different to one-to-one nat because the source and target networks do not need to be the same size. Any of pf's pool options are valid in this situation. Signed-off-by: Steve Kerrison <steve.kerrison@jcu.edu.au>
Member
|
The legacy outbound nat page is on its way out (#9515), which means there's a feature freeze. |
Author
When I was initially working on this the new page was read-only, so I suppose if that's no longer the case and it's usable on 16.1 then I'll see what needs updating there instead. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The old interface only lists interface addesses, not nets, and the rule parser parser only looks for interface names suffixed by
ip. In pf, interface address is used dynamically by being surrounded by parenthesis and includes the ":0" modifier to exclude aliases. By combining this with the ":network" modifier, source nat can also use an interface's network, dynamically, i.e. "($iface:network:0)".This is different to one-to-one nat because the source and target networks do not need to be the same size. Any of pf's pool options are valid in this situation.
Noticing PR #8495, I think updating the refactoring done there to include support for this would be fairly simple, with an update around https://github.com/opnsense/core/pull/8495/files#diff-fa864e1de379b514cb12d89d3e3c738b31c6c340fba099be98ba03520035c676R79
I made these changes because I wanted to source NAT onto a prefix delegated subnet, where the source subnet is larger than the target prefix and so masking/NPTv6 won't work, and the prefix is dynamic (DHCP assigned by ISP) so so must be based on an interface reference.