-
Notifications
You must be signed in to change notification settings - Fork 41
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
Gets confused by empty /proc/net/ip_tables_names #27
Comments
I can confirm this behaviour. And it took me quite a while to figure out, why it wasn't working respectively how iptables_raw is ment to work. I was setting up a new Debian (buster) system and had no experience with this module before. As far as I understand, debian buster has changed to nftables completely and these kernel modules are no longer needed. As there is no ansbile nftables module yet (ansible/ansible#27229), an easy fix would be, to change the default return value in
|
For now I switched back to iptables-legacy on my Debian 10 (buster) hosts. |
Same issue on Centos 8 with iptables v1.8.2 (nf_tables). The fix from @everlanes does only partially fix the issue. With the fix, rules are deployed correctly but the iptables rules are not saved to /etc/sysconfig/iptables. I could not yet figure out why the rules are not saved to file. |
I tried my solution again with a fresh installation and I have to admit, it wasn't working anymore. Previously it might have worked due to some changes I had made manually during testing. I checked the following solution with another fresh installation of debian buster and it worked for me:
It also preserved the iptables while rebooting. But: I think this is kind of hackisch. After all we are dealing with the new filtering infrastructure I see two clean solutions:
I will also stick with the first solution for now and hope for a nicer way with nftables in the future. |
I just created a merge request to add "kind of" nftables compatibility to this module. Of course a native nftables module would be a cleaner solution but my fix will do for most people. On systems using nftables as firewall backend, the nftables package and the nft command should be available to work. On systems using netfilter, the nft command must not be available. I only tested it on CentOS 7 / 8 for now. Please take a look at #30 |
As of Debian 10 (buster), the
iptables
commands by default are linked to theiptables-nft
equivalents.It seems that these commands do not cause the
iptable_filter
andip6_table_filter
modules to be loaded when rules are added to thefilter
table, and probably not the other relevant modules for the other tables. Those modules are loaded in Debian 9 and prior, as soon as any rule is modified.What then happens is that Ansible inserts the rules the first time, but then writes an empty save file to /etc/iptables/rules.v4 because it read in an empty /proc/net/ip_tables_names file and assumed there are no tables. Then at next boot of the target host the empty rule file is restored, Ansible never spots that anything has changed and life continues with an empty active ruleset.
I do not yet know if it is a bug in
iptables-nft
that it doesn't populate /proc/net/ip_tables_names.I was able to force the proc files to be populated by manually loading the
iptable_filter
andip6_table_filter
modules (then putting a file in /etc/modules-load.d/ to make that permanent). Possibly I could instead revert toiptables-legacy
.From other issues I suspect you will take the view that this project only supports what is now called iptables-legacy. I file this issue mainly so that others are aware, since the
iptables-nft
command is meant to offer backwards compatibility yet this seems to be a regression in behaviour that affects this project.The text was updated successfully, but these errors were encountered: