path: root/iptables/
diff options
authorOliver Ford <>2017-05-26 12:25:16 +0000
committerPablo Neira Ayuso <>2017-05-29 14:00:54 +0200
commit8d994bcf6be09cd0a13d6f22c6e01e98fb130415 (patch)
tree1521c2444d27f05569d282cc775bce1b4688adc2 /iptables/
parentf8e5ebc5986bffa682ed9e4497e3c19f19bf961e (diff)
iptables: Add file output option to iptables-save
Adds an option to output the results of iptables-save, ip6tables-save, and xtables-save save to a file. Updates the man page with this new option. Uses the dup2 call to replace stdout with the specified file. Error output is unchanged. This is a feature requested by a Gentoo developer in Bugzilla #905. Signed-off-by: Oliver Ford <> Signed-off-by: Pablo Neira Ayuso <>
Diffstat (limited to 'iptables/')
1 files changed, 9 insertions, 5 deletions
diff --git a/iptables/ b/iptables/
index 7f99d8a3..51e11f3e 100644
--- a/iptables/
+++ b/iptables/
@@ -19,27 +19,31 @@
-iptables-save \(em dump iptables rules to stdout
+iptables-save \(em dump iptables rules
-ip6tables-save \(em dump iptables rules to stdout
+ip6tables-save \(em dump iptables rules
\fBiptables\-save\fP [\fB\-M\fP \fImodprobe\fP] [\fB\-c\fP]
-[\fB\-t\fP \fItable\fP]
+[\fB\-t\fP \fItable\fP] [\fB\-f\fP \fIfilename\fP]
\fBip6tables\-save\fP [\fB\-M\fP \fImodprobe\fP] [\fB\-c\fP]
-[\fB\-t\fP \fItable\fP]
+[\fB\-t\fP \fItable\fP] [\fB\-f\fP \fIfilename\fP]
.B iptables-save
.B ip6tables-save
are used to dump the contents of IP or IPv6 Table in easily parseable format
-to STDOUT. Use I/O-redirection provided by your shell to write to a file.
+either to STDOUT or to a specified file.
\fB\-M\fR, \fB\-\-modprobe\fR \fImodprobe_program\fP
Specify the path to the modprobe program. By default, iptables-save will
inspect /proc/sys/kernel/modprobe to determine the executable's path.
+\fB\-f\fR, \fB\-\-file\fR \fIfilename\fP
+Specify a filename to log the output to. If not specified, iptables-save
+will log to STDOUT.
\fB\-c\fR, \fB\-\-counters\fR
include the current values of all packet and byte counters in the output