netstat
has indeed been deprecated by many distributions, though it's really much of the "net-tools" package (including ifconfig
, route
and arp
) that has been deprecated in favour of the "iproute2" package. iproute2 has evolved along with the latest Linux networking features, and the traditional utilities have not.
The iproute2 equivalent that you want is the little known nstat
, this provides the netstat -s
counters, albeit in a slightly different form:
raw counter names from /proc
are used, each prefixed with its class ("Udp", "Tcp", "TcpExt" etc)
netstat's long (and possibly localised) descriptions are not available
zero-value counters omitted by default
using consistent columnar output with the name and value in the first and second columns
third column shows the average over a configurable time window if you have started a background nstat (-d
daemon mode), or 0.0 if not
e.g. nstat
prints "UdpInDatagrams NNN" not "Udp: InDatagrams", and not the verbose netstat version of "Udp: NNN packets received".
nstat
also assumes you want incremental rather than absolute numbers, so the closest equivalent to netstat -s
is /sbin/nstat -asz
where the options are -a
use absolute counters, -s
don't keep history file, -z
don't omit zero-value counters.
ss
takes over the "socket" parts of netstat
, but not its complete function as you have found out. (ss
is actually better than netstat
in many cases, two specific ones are the ability to use filter expressions and the optional capability to use the tcp_diag
and inet_diag
Linux kernel modules to access kernel socket data more directly than via /proc
.)
Should you need to confirm the mapping for descriptive names, the net-tools source is the definitive reference: http://sourcecodebrowser.com/net-tools/1.60/statistics_8c_source.html
Doug Vitale provides a useful guide for finding the iproute2 equivalents of the older commands (it is unmaintained and slightly incomplete, it omits any reference to nstat
which has been part of the iproute2 package since at least 2004 kernel 2.6.x time).
net-tools lives on however, and you should be able to find a package for your distribution (or compile it yourself).
netstat
is deprecated. Usess
.tcpdump
allows one to capture live traffic, but does not store statistics in a waynetstat -s
shows.sysctl
output or the contents of various/proc/net/*
nodes.