For some reason I have no such file on my server..
root@serv:~# uname -a
Linux serv 5.4.0-87-generic #98~18.04.1-Ubuntu SMP Wed Sep 22 10:45:04 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
root@serv:~# cat /proc/net/stat/nf_conntrack
cat: /proc/net/stat/nf_conntrack: No such file or directory
But my conntrack is definitely enabled:
root@serv:~# lsmod | grep conntr
xt_conntrack 16384 1
nf_conntrack_netlink 45056 0
nf_conntrack 139264 2 xt_conntrack,nf_conntrack_netlink
nf_defrag_ipv6 24576 1 nf_conntrack
nf_defrag_ipv4 16384 1 nf_conntrack
libcrc32c 16384 1 nf_conntrack
nfnetlink 16384 1 nf_conntrack_netlink
x_tables 45056 3 xt_conntrack,iptable_filter,ip_tables
And conntrack -L
works perfectly.
But lnstat -f ip_conntrack
also shows the empty output.
What is the reason? Should I insert some kernel module for this file to appear in procfs?
The relevant required configuration needed to have conntrack available in
/proc
isCONFIG_NF_CONNTRACK_PROCFS
:OP's kernel appears to have been built with features described in this package:
linux-buildinfo-5.4.0-87-generic
.Alas content of
/usr/lib/linux/5.4.0-87-generic/config
from package above tells:So the two
/proc/
entries usually provided by conntrack:/proc/net/nf_conntrack
and/proc/net/stat/nf_conntrack
will not exist.As the documentation tells, this has been obsoleted by the
conntrack
tool which uses the netlink(7) kernel API instead.Most of the content of
/proc/net/stat/nf_conntrack
can be replaced by:which gives the number of entries (this is the first column of data present in
/proc/net/stat/nf_conntrack
) and:which gives the content of most of the other columns available in
/proc/net/stat/nf_conntrack
, sometimes for the (main)conntrack
table, sometimes for theexpect
table, one per CPU as well. A few statistics don't appear to be available this way (or might be hidden elsewhere, or might have been obsoleted ...).If you really need
/proc/net/stat/nf_conntrack
you'll have to switch to an other kernel with this feature available or rebuild the kernel with different options. This kernel option doesn't appear to be chosen by Ubuntu anymore, including in newer kernel versions.For reference, here's an example from a different kernel having this option and running with 4 CPUs: