-
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
Rootless Podman Wireguard container fails to configure iptables #15120
Comments
The answer to your question as to how rootless Podman can alter iptables rules when your user cannot is simple: Podman cannot do anything your user cannot do, so it can't make changes to the host's firewall rules. We can make limited changes inside the rootless network namespace, but any changes to the host's firewall config are not possible. If you need to make changes to the host's configuration, you will need a root container. I cannot recall having seen a working Wireguard (or other VPN) setup on rootless Podman, for reference (but I personally have a root container with an openvpn connection). |
@mheon thanks for claifying... I am in the process of moving 20 containers from docker and have managed to find work arounds for most things, but failing with this one. I had seen reports on a couple of forums that people had got this container working rootles but I have yet to find any real details on how that might be possible. I think my options are:
If anyone ever gets this working then please drop a comment below. Closing. |
You can run wireguard and iptables in a rootless container if the kernel modules are already loaded, compare https://github.com/containers/podman/blob/main/contrib/modules-load.d/podman-iptables.conf Also you need to give your container extra permissions with cap_add but looks liek you already take care of that. But as @mheon said you can only change the firewall rules in the container network namespace, it will not work if you use --network host for example. |
@Luap99 you have given me some hope... but I have yet to find a path forwards. On the host I ran
Running Switching into the container with
Which looks the same.
That warning for The container boot is still hanging though at the log:
Running this command manually within the container I get no feedback. I also tried swapping Thanks for the pointers. |
In #7816 (comment) we had been pointed at https://github.com/jcarrano/wg-podman Would this help to resolve this issue, if prevailing? |
@almereyda I think the use case is a little different, this looks to be for container connectivity and I was hoping just to run wireguard as a server for other devices to connect to (which required IPTABLES changes on the host which I couldn't get to work). There may be some useful ideas here though. |
Does podman on ub22 vs RHEL9 behaves different? Even I was trying to run wireguard with NET_ADMIN & NET_RAW, but it works great when the host is UB22, but it fails on RHEL9 with the permission issue. Btw the arch is arm64. Why does it behave differently here? EDIT: NVM, I had to include iptable_filter, iptable_nat modules explicitly !! |
@hasan4791 can you share your run command or compose file so I can see how you got it working. Thanks |
@scottsweb This is my start script,
And security info from podman debug command is
|
Apart from this, there are 2 things that need to be done when running in rootless mode.
For me, with these changes, I'm still not able to get the VPN working though it says handshake is successful. In the end, I started using rootful mode where everything works without the above changes. Figured out the problem, it was with MTU size. Had to update the mtu size for slirp4netns in containers.conf which resolved my issue. Now everything is working fine in rootless mode. |
Thanks for the tips @hasan4791 - I will do some testing. |
Could someone throw some light on this weird behavior. In rootless mode, with podman-restart service enabled for the non-root user, and after the node reboot, I'm getting this iptables errors. Update: Don't call me mad. This issue is getting resolved if I run a container in root mode which also uses iptables. For eg: If i have openvpn-as running as root container & wireguard in rootless container, everything works on reboot. Is it a bug or what? |
@Luap99 Ideas? |
@rhatdan Checked audit logs and getting these on reboot, but as i said, if i go back to root & come, there are no denials. Whats happening in the system?
Update: If i'm not wrong, these are the iptables-extended modules which is being loaded by iptables itself. I assume on first boot we had no modules loaded but then on running as root containers, it gets loaded and after that for rootless containers it is available as it is. Is there anyway to make it available to the rootless containers on boot without enabling "domain_kernel_load_modules". Please correct me if im wrong.
|
Some modules cannot be loaded by a rootless user, I know iptables-legacy needs this https://github.com/containers/podman/blob/main/contrib/modules-load.d/podman-iptables.conf. |
@Luap99 Hey Paul, thanks for looking. Btw i had already loaded iptables module on boot. Its just that the extended modules which the iptables loads on runtime is being denied. I thought of handling it in by having a custom policy. Btw would it be great, if we have a tunable parameter like "container_kernel_load_modules" to achieve this. |
Final update, if anyone is trying Rootless Wireguard on Fedora bases distros, following modules needs to be enabled
Thank everyone who all helped here and Sorry for hijacking here @scottsweb Would like to keep discussions at one place for future reference. |
@hasan4791 no problem at all. Glad you made some progress. Just to check, you enabled these as kernel modules? and there were no changes needed to the container? |
Right, also we need to run as root user in the rootles container btw. If you would like to know more, feel free to check out my automation that I'm currently using it to deploy in my servers. |
Unfortunately, it seems to require root privileges to run : containers/podman#15120
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
I am attempting to setup Wireguard in a rootless podman container on Fedora Silverblue 36 using https://hub.docker.com/r/linuxserver/wireguard. The container starts but either fails due to permissions errors, or fails silently (depending on which caps are added). I am not sure how the container will be able to modify IP tables when my user (on the host) is not able to.
Steps to reproduce the issue:
wireguard-tools
withrpm-ostree wireguard-tools
sudo modprobe wireguard
to load the wireguard moduledocker-compose up
Describe the results you received:
Without the cap
NET_RAW
the container fails to start with the following error:With the cap
NET_RAW
added (I found this as a recommendation in this repo), the container simply hangs on the iptables step:My user on the host does not have permissions to mess around with IPTABLES:
I have a feeling it might be stalling with
NET_RAW
due to SELinux but I am not too familar with it or how I would debug it.Describe the results you expected:
I would expect that with the correct caps the container would start.
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
):Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)
Yes
Additional environment details (AWS, VirtualBox, physical, etc.):
The text was updated successfully, but these errors were encountered: