`conntrack -L --src-nat --dst-nat` doesn't work with version 0.9.14
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Everyone,
With previous versions of conntrack [for eg. version 0.9.6]; you could list conntrack entries and have them filtered for both source and destination NAT. This was great for looking at all NAT entries at the same time.
However, it seems that in the current version that doesn't work i.e. you cannot filter entries for both source and destination NAT together. Filtering on either of the two types still works fine. I'm not quite sure about the history of this if any; so can someone point out whether this change was intentional or an oversight?
Thanks,
Mohit
Pablo Neira Ayuso
maintainerQuoted 5 lines · Mohit Mehta
Hi Everyone,
With previous versions of conntrack [for eg. version 0.9.6]; you could list conntrack entries and have them filtered for both source and destination NAT. This was great for looking at all NAT entries at the same time.
However, it seems that in the current version that doesn't work i.e. you cannot filter entries for both source and destination NAT together. Filtering on either of the two types still works fine. I'm not quite sure about the history of this if any; so can someone point out whether this change was intentional or an oversight?
Could you test if this patch helps?
conntrack: fix `-L --src-nat --dst-nat'
From: Pablo Neira Ayuso <[email protected]>
Since > 0.9.6, the conntrack listing with the options --src-nat and --dst-nat does not work. This patch fixes the problem.
--- src/conntrack.c | 22 +++++++++------------- 1 files changed, 9 insertions(+), 13 deletions(-)
src/conntrack.c +9 -13
@@ -635,27 +635,23 @@ filter_nat(const struct nf_conntrack *obj, const struct nf_conntrack *ct)uint32_t ip;if (options &CT_OPT_SRC_NAT ) { -if (!nfct_getobjopt (ct,NFCT_GOPT_IS_SNAT )) -return 1 ; -if (nfct_attr_is_set (obj,ATTR_SNAT_IPV4 )) { ip =nfct_get_attr_u32 (obj,ATTR_SNAT_IPV4 ); -if (ip !=nfct_get_attr_u32 (ct,ATTR_REPL_IPV4_DST )) -return 1 ; - } +if (ip ==nfct_get_attr_u32 (ct,ATTR_REPL_IPV4_DST )) +return 0 ; + }else if (nfct_getobjopt (ct,NFCT_GOPT_IS_SNAT )) +return 0 ; }if (options &CT_OPT_DST_NAT ) { -if (!nfct_getobjopt (ct,NFCT_GOPT_IS_DNAT )) -return 1 ; -if (nfct_attr_is_set (obj,ATTR_DNAT_IPV4 )) { ip =nfct_get_attr_u32 (obj,ATTR_DNAT_IPV4 ); -if (ip !=nfct_get_attr_u32 (ct,ATTR_REPL_IPV4_SRC )) -return 1 ; - } +if (ip ==nfct_get_attr_u32 (ct,ATTR_REPL_IPV4_SRC )) +return 0 ; + }else if (nfct_getobjopt (ct,NFCT_GOPT_IS_DNAT )) +return 0 ; } -return 0 ; +return 1 ; }static int counter;