iptables --list-rules command
PATCH 3/4 iptables --list-rules command
Adds iptables --list-rules (-S) command, acting as a combination of iptables --list and iptables-save.
The primary motivation behind this patch is to get iptables-save like output capabilities in iptables-restore, allowing "iptables-restore -n" to be used as a consistent API to iptables for all kind of operations, not only blind updates..
As a bonus iptables also gets the capability of printing the rules as-is.
This completely replaces the earlier patch which added the --rules option.
Regards
Henrik
include/ip6tables.h +1 -0
@@ -22,5 +22,6 @@ extern int do_command6(int argc, char *aextern int for_each_chain (int (*fn)(const ip6t_chainlabel ,int ,ip6tc_handle_t *),int verbose,int builtinstoo,ip6tc_handle_t *handle);extern int flush_entries (const ip6t_chainlabel chain,int verbose,ip6tc_handle_t *handle);extern int delete_chain (const ip6t_chainlabel chain,int verbose,ip6tc_handle_t *handle); +void print_rule (const struct ip6t_entry *e,ip6tc_handle_t *h,const char *chain,int counters);#endif /*_IP6TABLES_USER_H*/
include/iptables.h +2 -0
@@ -23,6 +23,8 @@ extern int flush_entries(const ipt_chain iptc_handle_t *handle);extern int for_each_chain (int (*fn)(const ipt_chainlabel ,int ,iptc_handle_t *),int verbose,int builtinstoo,iptc_handle_t *handle); +extern void print_rule (const struct ipt_entry *e, +iptc_handle_t *handle,const char *chain,int counters);/* kernel revision handling */ extern int kernel_version;
ip6tables-save.c +0 -193
199 lines not on this page · raw message
ip6tables.8.in +5 -0
@@ -197,6 +197,11 @@ arguments given. The exact rules are sup ip6tables -L -v .fi .TP +.BR "-S, --list-rules " "[\fIchain\fP]" +Print all rules in the selected chain. If no chain is selected, all +chains are printed like iptables-save. Like every other iptables command, +it applies to the specified table (filter is the default). +.TP .BR "-F, --flush " "[\fIchain\fP]" Flush the selected chain (all the chains in the table if none is given). This is equivalent to deleting all the rules one by one.
ip6tables.c +264 -16
359 lines not on this page · raw message
iptables-save.c +0 -205
211 lines not on this page · raw message
iptables.8.in +5 -0
@@ -205,6 +205,11 @@ arguments given. The exact rules are sup iptables -L -v .fi .TP +.BR "-S, --list-rules " "[\fIchain\fP]" +Print all rules in the selected chain. If no chain is selected, all +chains are printed like iptables-save. Like every other iptables command, +it applies to the specified table (filter is the default). +.TP .BR "-F, --flush " "[\fIchain\fP]" Flush the selected chain (all the chains in the table if none is given). This is equivalent to deleting all the rules one by one.
iptables.c +274 -15
362 lines not on this page · raw message
Quoted 8 lines · Henrik Nordstrom
Adds iptables --list-rules (-S) command, acting as a combination of iptables --list and iptables-save.
The primary motivation behind this patch is to get iptables-save like output capabilities in iptables-restore, allowing "iptables-restore -n" to be used as a consistent API to iptables for all kind of operations, not only blind updates..
Quoted 5 lines
As a bonus iptables also gets the capability of printing the rules as-is.
This completely replaces the earlier patch which added the --rules option.
Looks good to me. I'll let this sit on the list until tommomrrow in case anyone has comments.
Patrick McHardy
AppliedQuoted 8 lines · Henrik Nordstrom
Adds iptables --list-rules (-S) command, acting as a combination of iptables --list and iptables-save.
The primary motivation behind this patch is to get iptables-save like output capabilities in iptables-restore, allowing "iptables-restore -n" to be used as a consistent API to iptables for all kind of operations, not only blind updates..
Quoted 5 lines
As a bonus iptables also gets the capability of printing the rules as-is.
This completely replaces the earlier patch which added the --rules option.
Applied, thanks Henrik.