-
Notifications
You must be signed in to change notification settings - Fork 45
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
Docker support? #38
Comments
Docker issues IPTables rules / forwarding when containers are created depending on the configuration of the container, so if you start apf it flushes these rules. If you restart docker it will re-issue the docker modifications. However that isn't really convenient. If you search google there are a few options, one of which is using APF post_rules and disabling dockers iptables automation. I think if you run docker, and then issue iptables-save you will see what items you would need to add to the post rules in apf. Its not just APF that is having this issue, its an issue with dockers implementation. Be careful, even when having an iptables firewall active, creating a container with ports configured will open up those ports in the firewall. If anybody has an automated solution for docker/apf i really interested to use. |
I use the following approach by modifying #! /bin/sh
. /etc/default/apf-firewall
if [ "x$RUN" != "xyes" ] ; then
exit 0
fi
/sbin/iptables-save -t filter | egrep "filter|FORWARD|DOCKER|docker|COMMIT" > /tmp/iptables-save-filter-tables-docker
/sbin/iptables-save -t nat > /tmp/iptables-save-nat-tables-docker
/usr/sbin/apf -f >> /dev/null 2>&1
/usr/sbin/apf -s >> /dev/null 2>&1
/sbin/iptables-restore -c -n < /tmp/iptables-save-filter-tables-docker
/sbin/iptables-restore -c -n < /tmp/iptables-save-nat-tables-docker Also, you need configure Docker to start after apf-firewall, for this add the file [Unit]
After=network-online.target apf-firewall.service containerd.service |
When you flush, all rules gone, and when you start, the rules are setup.. then you restore docker rules, won't there be duplicate of rules since -n is specified? Also when restoring the filter table, the docker rules are not restore though.. tested this in almalinux 8, maybe just me. Please take a look, jasonwee@6e79b63 I resort to just restart docker https://github.com/jasonwee/advanced-policy-firewall/pull/5/files for 2 reasons. Guaranteed container works. No duplicates rules or shield from future any changes to docker rules or iptables/netfilter. |
…k. Commit it here for the work done
I think the rules are not duplicated because the following flush all rules: /usr/sbin/apf -f >> /dev/null 2>&1 I faced the problem with duplicated rules but was due to the iptables version, I noted that apf-firwall doesn't work fine with nf_tables. |
for me, when the nat rules reloaded in almalinux 8, it did not flush, i had to load the module iptable_nat, this is also in my patch too. |
It seems that APF doesn't support docker in that if you enable APF docker containers are no longer accessible/can't access the internet. Is there any way to resolve this?
The text was updated successfully, but these errors were encountered: