I need to configure iptables on a linux machine with running docker containers. If I save iptables rules with iptables-save > /etc/iptables/rules.v4
, rules from all chains will be written to file.
But I want to save only INPUT, OUTPUT and DOCKER-USER chains, and don't want chains DOCKER, DOCKER-ISOLATION-STAGE-1, etc to be saved, since they contain rules added by docker automatically, which will be irrelevant after reboot.
As far as I know, iptables-save
can save specific tables, but not specific chains.
Currently I consider to combine iptables-save
with grep
to cut rules from unwanted chains. Is there any better way to achieve same result?