NETSTAT(1) | MidnightBSD General Commands Manual | NETSTAT(1) |
netstat
— show
network status and statistics
netstat
--libxo
] [-46AaCLnPRSTWx
]
[-f
protocol_family | -p
protocol]
[-M
core]
[-N
system]netstat
-i
| -I
interface--libxo
] [-46abdhnW
]
[-f
address_family]
[-M
core]
[-N
system]netstat
-w
wait--libxo
]
[-I
interface]
[-46d
]
[-M
core]
[-N
system]
[-q
howmany]netstat
-s
--libxo
] [-46sz
]
[-f
protocol_family | -p
protocol]
[-M
core]
[-N
system]netstat
-i
| -I
interface -s
--libxo
] [-46s
]
[-f
protocol_family | -p
protocol]
[-M
core]
[-N
system]netstat
-m
--libxo
]
[-M
core]
[-N
system]netstat
-B
--libxo
] [-z
]
[-I
interface]netstat
-r
--libxo
] [-46nW
]
[-F
fibnum]
[-f
address_family]netstat
-rs
--libxo
] [-s
]
[-M
core]
[-N
system]netstat
-g
--libxo
] [-46W
]
[-f
address_family]netstat
-gs
--libxo
] [-46s
]
[-f
address_family]
[-M
core]
[-N
system]netstat
-Q
--libxo
]The netstat
command symbolically displays
the contents of various network-related data structures. There are a number
of output formats, depending on the options for the information
presented.
netstat
[-46AaCLnRSTWx
]
[-f
protocol_family | -p
protocol]
[-M
core]
[-N
system]The default display for active sockets shows the local and
remote addresses, send and receive queue sizes (in bytes), protocol, and
the internal state of the protocol. Address formats are of the form
“host.port” or “network.port” if a socket's
address specifies a network but no specific host address. When known,
the host and network addresses are displayed symbolically according to
the databases hosts(5)
and networks(5),
respectively. If a symbolic name for an address is unknown, or if the
-n
option is specified, the address is printed
numerically, according to the address family. For more information
regarding the Internet IPv4 “dot format”, refer to
inet(3). Unspecified,
or “wildcard”, addresses and ports appear as
“*
”.
--libxo
-4
-6
-A
-a
-c
-C
-L
-n
-P
-R
M_HASHTYPE_*
.-S
-n
)
but show ports symbolically.-T
-W
-x
The -x
flag causes
netstat
to output all the information
recorded about data stored in the socket buffers. The fields
are:
R-MBUF |
Number of mbufs in the receive queue. |
S-MBUF |
Number of mbufs in the send queue. |
R-CLUS |
Number of clusters, of any type, in the receive queue. |
S-CLUS |
Number of clusters, of any type, in the send queue. |
R-HIWA |
Receive buffer high water mark, in bytes. |
S-HIWA |
Send buffer high water mark, in bytes. |
R-LOWA |
Receive buffer low water mark, in bytes. |
S-LOWA |
Send buffer low water mark, in bytes. |
R-BCNT |
Receive buffer byte count. |
S-BCNT |
Send buffer byte count. |
R-BMAX |
Maximum bytes that can be used in the receive buffer. |
S-BMAX |
Maximum bytes that can be used in the send buffer. |
rexmt |
Time, in seconds, to fire Retransmit Timer, or 0 if not armed. |
persist |
Time, in seconds, to fire Retransmit Persistence, or 0 if not armed. |
keep |
Time, in seconds, to fire Keep Alive, or 0 if not armed. |
2msl |
Time, in seconds, to fire 2*msl TIME_WAIT Timer, or 0 if not armed. |
delack |
Time, in seconds, to fire Delayed ACK Timer, or 0 if not armed. |
rcvtime |
Time, in seconds, since last packet received. |
-f
protocol_family-p
protocol-M
-N
netstat
-i
| -I
interface
[-46abdhnW
]
[-f
address_family]
[-M
core]
[-N
system]*
”) after an interface name
indicates that the interface is “down”.
When netstat
is invoked with
-i
(all interfaces) or
-I
interface, it provides
a table of cumulative statistics regarding packets transferred, errors,
and collisions. The network addresses of the interface and the maximum
transmission unit (“mtu”) are also displayed.
-4
-6
-a
-b
-d
-h
-n
-W
-i
option, and this
option has little effect.-f
protocol_familynetstat
-w
wait
[-I
interface]
[-46d
]
[-M
core]
[-N
system]
[-q
howmany]When netstat
is invoked with the
-w
option and a wait
interval argument, it displays a running count of statistics related to
network interfaces. An obsolescent version of this option used a numeric
parameter with no option, and is currently supported for backward
compatibility. By default, this display summarizes information for all
interfaces. Information for a specific interface may be displayed with
the -I
interface
option.
-I
interface-4
-6
-d
-M
-N
-q
netstat
-s
[-46sz
]
[-f
protocol_family | -p
protocol]
[-M
core]
[-N
system]-4
-6
-s
-s
is repeated, counters with a value of
zero are suppressed.-z
-f
protocol_family-p
protocol-M
-N
netstat
-i
| -I
interface -s
[-46s
]
[-f
protocol_family | -p
protocol]
[-M
core]
[-N
system]-4
-6
-s
-s
is repeated, counters with a value of
zero are suppressed.-f
protocol_family-p
protocol-M
-N
netstat
-m
[-M
core]
[-N
system]-M
-N
netstat
-B
[-z
]
[-I
interface]The bpf(4)
flags displayed when netstat
is invoked with the
-B
option represent the underlying parameters of
the bpf peer. Each flag is represented as a single lower case letter.
The mapping between the letters and flags in order of appearance
are:
p |
Set if listening promiscuously |
i |
BIOCIMMEDIATE
has been set on the device |
f |
BIOCGHDRCMPLT
status: source link addresses are being filled
automatically |
s |
BIOCGSEESENT
status: see packets originating locally and
remotely on the interface. |
a |
Packet reception generates a signal |
l |
BIOCLOCK
status: descriptor has been locked |
For more information about these flags, please refer to bpf(4).
-z
netstat
-r
[-46AnW
]
[-F
fibnum]
[-f
address_family]
[-M
core]
[-N
system]When netstat
is invoked with the
routing table option -r
, it lists the available
routes and their status. Each route consists of a destination host or
network, and a gateway to use in forwarding packets. The flags field
shows a collection of information about the route stored as binary
choices. The individual flags are discussed in more detail in the
route(8) and
route(4) manual pages.
The mapping between letters and flags is:
1 |
RTF_PROTO1 |
Protocol specific routing flag #1 |
2 |
RTF_PROTO2 |
Protocol specific routing flag #2 |
3 |
RTF_PROTO3 |
Protocol specific routing flag #3 |
B |
RTF_BLACKHOLE |
Just discard pkts (during updates) |
b |
RTF_BROADCAST |
The route represents a broadcast address |
D |
RTF_DYNAMIC |
Created dynamically (by redirect) |
G |
RTF_GATEWAY |
Destination requires forwarding by intermediary |
H |
RTF_HOST |
Host entry (net otherwise) |
L |
RTF_LLINFO |
Valid protocol to link address translation |
M |
RTF_MODIFIED |
Modified dynamically (by redirect) |
R |
RTF_REJECT |
Host or net unreachable |
S |
RTF_STATIC |
Manually added |
U |
RTF_UP |
Route usable |
X |
RTF_XRESOLVE |
External daemon translates proto to link address |
Direct routes are created for each interface attached to the local host; the gateway field for such entries shows the address of the outgoing interface. The refcnt field gives the current number of active uses of the route. Connection oriented protocols normally hold on to a single route for the duration of a connection while connectionless protocols obtain a route while sending to the same destination. The use field provides a count of the number of packets sent using that route. The interface entry indicates the network interface utilized for the route.
-4
-6
-n
-W
-F
-F
is
not specified, the default routing table is displayed.-f
-M
-N
netstat
-rs
[-s
]
[-M
core]
[-N
system]-s
-s
is repeated, counters with a value of
zero are suppressed.-M
-N
netstat
-g
[-46W
]
[-f
address_family]
[-M
core]
[-N
system]inet
and
inet6
address families.
-4
-6
-W
-f
protocol_family-M
-N
netstat
-gs
[-46s
]
[-f
address_family]
[-M
core]
[-N
system]-4
-6
-s
-s
is repeated, counters with a value of
zero are suppressed.-f
protocol_family-M
-N
netstat
-Q
C |
NETISR_SNP_FLAGS_M2CPUID |
Able to map mbuf to cpu id |
D |
NETISR_SNP_FLAGS_DRAINEDCPU |
Has queue drain handler |
F |
NETISR_SNP_FLAGS_M2FLOW |
Able to map mbuf to flow id |
Some options have the general meaning:
-4
-f
inet
(Show only IPv4)-6
-f
inet6
(Show only IPv6)-f
address_family, -p
protocolinet
(AF_INET
)divert
,
icmp
, igmp
,
ip
, ipsec
,
pim, sctp
, tcp
,
udp
inet6
(AF_INET6
)icmp6
,
ip6
, ipsec6
,
rip6
, sctp
,
tcp
, udp
pfkey
(PF_KEY
)pfkey
netgraph
,
ng
(AF_NETGRAPH
)ctrl
,
data
unix
(AF_UNIX
)link
(AF_LINK
)The program will complain if protocol is unknown or if there is no statistics routine for it.
-M
-N
-n
netstat
attempts to resolve addresses and ports,
and display them symbolically.-W
-n
option if necessary to avoid ambiguity.fstat(1), nfsstat(1), procstat(1), ps(1), sockstat(1), libxo(3), xo_parse_args(3), bpf(4), inet(4), route(4), unix(4), hosts(5), networks(5), protocols(5), services(5), iostat(8), route(8), trpt(8), vmstat(8), mbuf(9)
The netstat
command appeared in
4.2BSD.
IPv6 support was added by WIDE/KAME project.
The notion of errors is ill-defined.
September 25, 2020 | midnightbsd-3.1 |