-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
CNI: Make firewalld rules --permanent #5431
Comments
I don't think we can do this because we want the rules to disappear after reboot. We've talked about this before, and the best we think we can do is offer a command that forces network reconfiguration for all running containers, recreating the rules. |
@mheon doesnt this also make some assumptions about the network stack being exactly the same each time as well? Given that we have zero interaction with firewalld itself, this seems nearly impossible. would it be possible to have something like a run-hook option where an executable could be run once the container state hit running or some such? of course, this could be done nicely with systemd as well and is maybe the more appropriate approach. |
If we do it any later, we end up with a race where traffic after the container started but before the network started will be lost. We can probably preserves IP address and MAC address on container recreation, even for non-static IP and MAC (we have a mechanism built-in already for doing this, originally for checkpoint/restore). I think we can probably duplicate the network configuration "well enough" with this (it works for checkpoint/restore on a different system, which seems promising) |
I've encountered with this problem too.
reload firewalld rules:
sources empty now:
try restart one of the container:
try restart again, this time it will success:
and got back:
ps: I even use
|
Although this is really annoying, as I recall Docker + firewalld worked the very same way. For me what worked is to use a container specific OS (like OpenSUSE MicroOS, Fedora CoreOS) explicitly dedicated for containers and leave network and firewall management to podman alone. I can use firewall rules outside of this VM. |
A friendly reminder that this issue had no activity for 30 days. |
@mheon Any movement on this one? |
No. I do want to add a command to do this, but there is no way we'll have time until Podmanv2 is done. |
To my understanding, firewalld and nftables were designed to solve this exact type of problem:
... from: https://developers.redhat.com/blog/2018/08/10/firewalld-the-future-is-nftables/ I guess podman/CNI would have to use nftables and create own tables. And leave firewalld to the user's local customization, only. Then firewalld-cmd --reload will just affect the user's stuff. Have you investigated this? Are there plans for this? |
I just ran into this as well and thinking through it, it makes sense. I'm not familiar enough with the intimate details, but seems like CNI doesn't have any sort of daemon (sort of the point, I guess), would it be possible to use a dbus-activated service (via systemd) that could examine the state of containers and recreate the appropriate entries when firewalld reloads, e.g. when |
Same here with Podman 1.6.4 on RHEL7.7 EUS. We are using systems maintained by central team with Puppet and they run firewalld --reload every 30 minutes, this is breaking the iptables and the services in the containers are not working anymore. |
As said before, Can I ask why you are reloading firewalld on such a regular basis? I don't think I've heard of anyone doing that before, and it's definitely not something I think we (or the CNI maintainers) have considered. |
OK. Let's say it differently. |
What about adding a |
That doesn't solve the fundamental problem that the rules will survive reboot, and the CNI plugins do not deal well with reboots - we'll leak rules if any container is still running when the system is shut down, and that will break things badly when the IP in question is reused for a fresh container. Podman itself does not directly create the rules, so I can't hack around this during our usual post-reboot cleanup because I don't know what rules need to be changed. The CNI plugins are theoretically safe to call on an already-dead container after a reboot to finalize cleanup of things like these firewall rules, but this has never actually worked for us. |
as a workaround, I managed to go over this issue by moving Centos 8 firewall configuration from nftables to iptables |
I found the best workaround for now was to run : firewall-cmd --permanent --zone=trusted --add-interface=cni-podman0 but not sure if this introduces a security issue in anyway. |
My bad. It does not work because podman populates trusted sources not trusted interfaces. On a reboot the source disappears and the conatiner is unreachable. I thought the workaround I suggested had fixed this yesterday but just confirmed it is actually still in the same position. |
I see the same problem that the podman rules go away regular. The reason for the firewalld reload here are intrusion detection tools, which reconfigure the firewall according to entries they find in the logs. |
Regarding the reload thing, on Fedora, NetworkManager has this postinstall line: test -f /usr/bin/firewall-cmd && firewall-cmd --reload --quiet || : Meaning when you upgrade the package, you lose rules created by podman. |
For work-around/current state please see, 29-container-related-firewall-rules-are-lost-after-reloading-firewalld |
Nice solution. On "Red Hat Enterprise Linux release 8.5 (Ootpa)" solution with 2 .service files is working for
Thank you all. |
@edsantiago PTAL |
I'm not opposed, though I'm still in favor of integrating this into Aardvark at some point in the future (4.1?) so we can automatically handle the reload there, no extra systemd service required. |
Sorry, I don't think I can review this: I don't know much about firewalld, and know even less about dbus. |
@githubcek Please open a PR to add you firewall script, we can ship this with Podman and not enable it by default, then we can ask people to try it out. |
On my systems I've been using a single service to react to firewalld startup and reload events. This service also parses the output of (I think I put this into another similar bug already, but don't have the reference handy, sorry about that). This seems to work fine for me but I think condensing it into a single linen shell script is... not great. A short Python script would be much clearer. If you'd accept it in Podman then I can work on a PR--let me know. (I forget why I didn't use
|
firewalld reload causes the podman network rules to be removed. It is being tracked at containers/podman#5431. In the mean time, add a workaround service to rebuild the rules when firewalld is started or reloaded.
firewalld reload causes the podman network rules to be removed. It is being tracked at containers/podman#5431. In the mean time, add a workaround service to rebuild the rules when firewalld is started or reloaded.
firewalld reload causes the podman network rules to be removed. It is being tracked at containers/podman#5431. In the mean time, add a workaround service to rebuild the rules when firewalld is started or reloaded.
I've been waiting for a one-file, no-script workaround to this issue before making the switch to firewalld and @yrro's service has been working well for me. Thanks! Hope to see a proper solution integrated soon. |
A friendly reminder that this issue had no activity for 30 days. |
Not likely to happen on CNI, but maybe netavark. |
I just ran into this issue on RHEL8, |
Aside from the linked systemd/scripting workaround, there are no immediate plans, though we have ideas about integrating a DBus listener into Aardvark to handle reload events. |
Thanks @mheon, we'll keep using the workaround for now then. |
While work on this is going on, is it okay if we add the systemd unit file within podman.spec? |
This is fixed with netavark v1.9 and a new systemd service: https://blog.podman.io/2023/11/new-netavark-firewalld-reload-service/ Thus I am going to close this issue, we will not fix this for CNI. |
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
I configured CNI to use firewalld as firewall backend and added my podman network interface to the
trusted
zone. When I'm reloading firewalld (firewall-cmd --reload
) all my podman related rules go missing. I'd like to have the ability to make the podman firewalld rules --permanent.(I'm starting my containers as root.)
Steps to reproduce the issue:
Start container
firewall-cmd --reload
Rules are missing.
Describe the results you received:
Describe the results you expected:
Rules don't go missing.
Additional information you deem important (e.g. issue happens only occasionally):
Output of
podman version
:Output of
podman info --debug
:Package info (e.g. output of
rpm -q podman
orapt list podman
):Additional environment details (AWS, VirtualBox, physical, etc.):
physical server
The text was updated successfully, but these errors were encountered: