-
Notifications
You must be signed in to change notification settings - Fork 336
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
T6687: add fqdn support to nat rules. #4024
Conversation
👍 |
✅ No issues found in unused-imports check.. Please refer the workflow run |
@@ -43,4 +56,8 @@ table ip vyos_nat { | |||
|
|||
{{ group_tmpl.groups(firewall_group, False, True) }} | |||
} | |||
|
|||
{% if ip_fqdn.items() %} | |||
# use-domain-resolver=yes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does nothing
Is it correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used a flag, in oder to start/stop vyos-domain resolver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolas-fort The question is why the line is always generated with a #
before it — that means the line is commented out and will not have any effect, unless Viacheslav and I are missing anything about the config file syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, to nftables it does nothing. As you said, it's always generated with #
, so it's a comment. But while applying firewall and nat rules, it checks if that comment is present in those files, in order to start/stop vyos-domain-resolver service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmbaturin The line seems to be picked up by a file contents check in the conf script.
Though not sure why the ip_fqdn
boolean check is insufficient here @nicolas-fort ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vyos-domain-resolver
now updates domains and/or fqdn entries, if they are configured in firewall and NAT.
- While parsing firewall rules, if fqdn or group-domains are used, then this comment is added to /run/nftables.conf as a flag that will be checked by nat scripts (of course, if nat is configured)
- While parsing nat rules, if fqdn are used, then this comment is added to /run/nftables_nat.conf as a flag that will be checked by firewall scripts (of course, if firewall is configured).
Since only once service handles this translations, while parsing one part of the config (for example firewall), we need to know if fqdn are configured in the other feature (nat).
I thought that would be better this approach, and check if comments are present in those files in order to decide to stop/start vypos-domain-resolver service, rather than while parsing one feature (for example nat), also grab the full configuration of the other feature (in the example would be firewall), and then decide if the service should be started or stopped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a bad feeling about such action at a distance, to be fair. At the very least it should be documented in the generated file, why a line that has no effect within that file is included in it.
But I think we should look for other solutions before we take this route. In the worst case, can we just enable the resolver daemon by default? It does nothing when there are no domain groups, and doesn't take much memory or CPU when idle, does it?
I'm marking this one as Draft while working on changes. |
5659884
to
20d0593
Compare
Fails:
cat /run/nftables_nat.conf
nft check:
Version:
|
@@ -18,6 +18,7 @@ | |||
<help>NAT destination parameters</help> | |||
</properties> | |||
<children> | |||
#include <include/firewall/fqdn.xml.i> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FQDN should be multi
, isn't it?
vyos@r14# set nat source rule 100 destination fqdn example.com
[edit]
vyos@r14# set nat source rule 100 destination fqdn n1.example.com
[edit]
vyos@r14# set nat source rule 100 destination fqdn n2.example.com
[edit]
vyos@r14# set nat source rule 100 destination fqdn n3.example.com
[edit]
vyos@r14# show nat source rule 100 destination
+fqdn n3.example.com
[edit]
vyos@r14#
one FQDN per rule is inconvenient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should steer users to use a group for multiple per rule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, this is analogous to the firewall syntax, which supports either a group (including a domain group) or a single FQDN. Domain groups are supported in NAT.
Fixed:
And:
I've also added an extra entry in smoketests |
@@ -18,6 +18,7 @@ | |||
<help>NAT destination parameters</help> | |||
</properties> | |||
<children> | |||
#include <include/firewall/fqdn.xml.i> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, this is analogous to the firewall syntax, which supports either a group (including a domain group) or a single FQDN. Domain groups are supported in NAT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to approve this, sorry it's taken so long.
Only comments are that I'm not a fan of the use of the temporary file in /run for other conf scripts to pick up as a "signal". But agree there isn't really a clean/performant solution for this at the moment (I'm talking to John about how we should best go about it).
@Mergifyio backport circinus |
✅ Backports have been created
|
Change Summary
Types of changes
Related Task(s)
Related PR(s)
Component(s) name
nat
Proposed changes
How to test
Smoketest result
Checklist: