


Stop iptables, delete or move the "rules-save" file, and I believe you'll have the default rules the next time iptables is started (at least with openrc as /etc/init.d/iptables sets up some defaults). I was working with iptables and have made some mistakes to where I'd like to flush everything and reload with the configuration that comes with Gentoo, but not sure how.īy default, the location where rules are saved is IPTABLES_SAVE=/var/lib/iptables/rules-save as defined in /etc/conf.d/iptables. Posted: Fri 8:40 pm Post subject: reload iptables w/ initial settings Gentoo Forums Forum Index Networking & Security It's just the only thing I found by searching for interactive iptables editing.Gentoo Forums :: View topic - reload iptables w/ initial settings You might also be interested in the following script: See the following post for further discussion of this subject:

This actually isn't too much different from how crontab -e works, which just automatically saves the active crontab to a file in the /var/spool/cron/crontabs directory, which is what causes the crontab to be persistent. Iptables-restore "$" > /etc/iptables/rules.v4 # Try to load the rules and update the persistent rules if no errors occur # Edit the rules interactively with a text editor # Create a temporary file to store the new rules Here is a simple example: #!/usr/bin/env bash I don't know of an interactive command for editing iptables rules like what you're describing, but it should be pretty easy to roll your own. So to apply your rules and have them persist you would follow the same steps as above, but edit the iptables-persistent files instead, e.g.: iptables-save > vim iptables-restore /etc/iptables/rules.v4 The iptables-persistent service checks in the following locations: /etc/iptables/rules.v4 In general, you can edit the active iptables rules for IPv4 with a text editor by using the iptables-save command to write the rules to a file and then using the iptables-restore command to reload the new rules after you're done, e.g.: iptables-save > vim iptables-restore rules.v4įor IPv6 you would use the analogous commands ip6tables-save and ip6tables-restore, i.e.: ip6tables-save > vim ip6tables-restore rules.v6
