---
name: "netstat"
section: "1"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd", "openbsd", "macos"]
url: "https://new.carta.tech/netstat"
---

# netstat(1)

show network status and statistics

## NAME

**netstat** – show network status and statistics

## SYNOPSIS

- **netstat**

  \[**-j** *jail*\] \[**--libxo**\] \[**-46AaCLnPRSTWx**\] \[**-f** *protocol\_family* \| **-p** *protocol*\]

- **netstat** **-i** \| **-I** *interface*

  \[**-j** *jail*\] \[**--libxo**\] \[**-46abdhnW**\] \[**-f** *address\_family*\] \[**-M** *core*\] \[**-N** *system*\]

- **netstat** **-w** *wait*

  \[**-j** *jail*\] \[**--libxo**\] \[**-I** *interface*\] \[**-46d**\] \[**-M** *core*\] \[**-N** *system*\] \[**-q** *howmany*\]

- **netstat** **-s**

  \[**-j** *jail*\] \[**--libxo**\] \[**-46sz**\] \[**-f** *protocol\_family* \| **-p** *protocol*\] \[**-M** *core*\] \[**-N** *system*\]

- **netstat** **-i** \| **-I** *interface* **-s**

  \[**-j** *jail*\] \[**--libxo**\] \[**-46s**\] \[**-f** *protocol\_family* \| **-p** *protocol*\] \[**-M** *core*\] \[**-N** *system*\]

- **netstat** **-m**

  \[**-j** *jail*\] \[**--libxo**\] \[**-M** *core*\] \[**-N** *system*\]

- **netstat** **-B**

  \[**-j** *jail*\] \[**--libxo**\] \[**-z**\] \[**-I** *interface*\]

- **netstat** **-r**

  \[**-j** *jail*\] \[**--libxo**\] \[**-46nW**\] \[**-F** *fibnum*\] \[**-f** *address\_family*\]

- **netstat** **-rs**

  \[**-j** *jail*\] \[**--libxo**\] \[**-s**\] \[**-M** *core*\] \[**-N** *system*\]

- **netstat** **-g**

  \[**-j** *jail*\] \[**--libxo**\] \[**-46W**\] \[**-F** *fibnum*\] \[**-f** *address\_family*\]

- **netstat** **-gs**

  \[**-j** *jail*\] \[**--libxo**\] \[**-46s**\] \[**-f** *address\_family*\] \[**-M** *core*\] \[**-N** *system*\]

- **netstat** **-Q**

  \[**-j** *jail*\] \[**--libxo**\]

- **netstat** **-o**

  **-4** \| **-6** \[**-j** *jail*\] \[**--libxo**\]

- **netstat** **-os**

  \[**-j** *jail*\] \[**--libxo**\] \[**-s**\] \[**-M** *core*\] \[**-N** *system*\]

- **netstat** **-O**

  **-4** \| **-6** \[**-j** *jail*\] \[**--libxo**\]

## DESCRIPTION

The **netstat** command shows the contents of various network-related data structures. The arguments passed determine which of the below output formats the command uses.

-

  **netstat** \[**-46AaCLnRSTWx**\] \[**-f** *protocol\_family* \| **-p** *protocol*\] \[**-j** *jail*\] Display a list of active sockets (protocol control blocks) for each network protocol.

  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)](/hosts/5.md) and [networks(5)](/networks/5.md), 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)](/inet/3.md). Unspecified, or “wildcard”, addresses and ports appear as “\*”.

  - **--libxo**

    Generate output via [libxo(3)](/libxo/3.md) in a selection of different human and machine readable formats. See [xo\_options(7)](/xo_options/7.md) for details on command line arguments.

  - **-4**

    Show IPv4 only. See GENERAL OPTIONS.

  - **-6**

    Show IPv6 only. See GENERAL OPTIONS.

  - **-A**

    Show the address of a protocol control block (PCB) associated with a socket; used for debugging.

  - **-a**

    Show the state of all sockets; normally sockets used by server processes are not shown.

  - **-c**

    Show the used TCP stack for each session.

  - **-C**

    Show the congestion control algorithm and diagnostic information of TCP sockets.

  - **-L**

    Show the size of the various listen queues. The first count shows the number of unaccepted connections, the second count shows the amount of unaccepted incomplete connections, and the third count is the maximum number of queued connections.

  - **-n**

    Do not resolve numeric addresses and port numbers to names. See GENERAL OPTIONS.

  - **-P**

    Display the log ID for each socket.

  - **-R**

    Display the flowid and flowtype for each socket. flowid is a 32 bit hardware specific identifier for each flow. flowtype defines which protocol fields are hashed to produce the id. A complete listing is available in *sys/mbuf.h* under M\_HASHTYPE\_\*.

  - **-S**

    Show network addresses as numbers (as with **-n**) but show ports symbolically.

  - **-T**

    Display diagnostic information from the TCP control block. Fields include the number of packets requiring retransmission, received out-of-order, and those advertising a zero-sized window.

  - **-W**

    Avoid truncating addresses even if this causes some fields to overflow.

  - **-x**

    Display socket buffer and TCP timer statistics for each internet socket.

    The **-x** flag causes **netstat** to output all the information recorded about data stored in the socket buffers. The fields are:

    | | |
    | --- | --- |
    | 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*

    Filter by *protocol\_family*. See GENERAL OPTIONS.

  - **-p** *protocol*

    Filter by *protocol*. See GENERAL OPTIONS.

  - **-j** *jail*

    Run inside a jail. See GENERAL OPTIONS.

-

  **netstat** **-i** \| **-I** *interface* \[**-46abdhnW**\] \[**-f** *address\_family*\] \[**-M** *core*\] \[**-N** *system*\] \[**-j** *jail*\] Show the state of all network interfaces or a single *interface* which have been auto-configured (interfaces statically configured into a system, but not located at boot time are not shown). An asterisk (“\*”) 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. If both **-i** and **-I** are specified, **-I** overrides any instances of **-i**.

  - **-4**

    Show IPv4 only. See GENERAL OPTIONS.

  - **-6**

    Show IPv6 only. See GENERAL OPTIONS.

  - **-a**

    Multicast addresses currently in use are shown for each Ethernet interface and for each IP interface address. Multicast addresses are shown on separate lines following the interface address with which they are associated.

  - **-b**

    Show the number of bytes in and out.

  - **-d**

    Show the number of dropped output packets.

  - **-h**

    Print all counters in human readable form.

  - **-n**

    Do not resolve numeric addresses and port numbers to names. See GENERAL OPTIONS.

  - **-W**

    Avoid truncating addresses even if this causes some fields to overflow. See GENERAL OPTIONS. However, in most cases field widths are determined automatically with the **-i** option, and this option has little effect.

  - **-f** *protocol\_family*

    Filter by *protocol\_family*. See GENERAL OPTIONS.

  - **-j** *jail*

    Run inside a jail. See GENERAL OPTIONS.

-

  **netstat** **-w** *wait* \[**-I** *interface*\] \[**-46d**\] \[**-M** *core*\] \[**-N** *system*\] \[**-q** *howmany*\] \[**-j** *jail*\] At intervals of *wait* seconds, display the information regarding packet traffic on all configured network interfaces, or a single *interface* if **-I** is specified.

  An obsolescent version of this option used a numeric parameter with no option, and is currently supported for backward compatibility.

  - **-I** *interface*

    Only show information regarding *interface*

  - **-4**

    Show IPv4 only. See GENERAL OPTIONS.

  - **-6**

    Show IPv6 only. See GENERAL OPTIONS.

  - **-d**

    Show the number of dropped output packets.

  - **-M**

    Use an alternative core. See GENERAL OPTIONS.

  - **-N**

    Use an alternative kernel image. See GENERAL OPTIONS.

  - **-q**

    Exit after *howmany* outputs. A value of zero indicates no limit, and is the default.

  - **-j** *jail*

    Run inside a jail. See GENERAL OPTIONS.

-

  **netstat** **-o** **-4** \| **-6** \[**-j** *jail*\] Print nexthop (nhops) information associated with routing entries. When used with **-4** or **-6**, limit the output to IPv4 or IPv6 routes respectively. This option provides details about individual nexthop addresses used in routing decisions.

  - **-j** *jail*

    Run inside a jail. See GENERAL OPTIONS.

-

  **netstat** **-os** \[**-s**\] \[**-M** *core*\] \[**-N** *system*\] \[**-j** *jail*\] Display nexthop statistics.

  - **-s**

    If **-s** is repeated, counters with a value of zero are suppressed.

  - **-M**

    Use an alternative core See GENERAL OPTIONS.

  - **-N**

    Use an alternative kernel image See GENERAL OPTIONS.

  - **-j** *jail*

    Run inside a jail. See GENERAL OPTIONS.

-

  **netstat** **-O** **-4** \| **-6** \[**-j** *jail*\] Print nexthop groups (nhgrp) information associated with routing entries. When used with **-4** or **-6**, restrict the output to IPv4 or IPv6 nexthop groups respectively. This option shows grouped nexthop entries for multipath or load-balanced routing setups.

  - **-j** *jail*

    Run inside a jail. See GENERAL OPTIONS.

-

  **netstat** **-s** \[**-46sz**\] \[**-f** *protocol\_family* \| **-p** *protocol*\] \[**-M** *core*\] \[**-N** *system*\] \[**-j** *jail*\] Display system-wide statistics for each network protocol.

  - **-4**

    Show IPv4 only. See GENERAL OPTIONS.

  - **-6**

    Show IPv6 only. See GENERAL OPTIONS.

  - **-s**

    If **-s** is repeated, counters with a value of zero are suppressed.

  - **-z**

    Reset statistic counters after displaying them.

  - **-f** *protocol\_family*

    Filter by *protocol\_family*. See GENERAL OPTIONS.

  - **-p** *protocol*

    Filter by *protocol*. See GENERAL OPTIONS.

  - **-M**

    Use an alternative core. See GENERAL OPTIONS.

  - **-N**

    Use an alternative kernel image See GENERAL OPTIONS.

  - **-j** *jail*

    Run inside a jail. See GENERAL OPTIONS.

-

  **netstat** **-i** \| **-I** *interface* **-s** \[**-46s**\] \[**-f** *protocol\_family* \| **-p** *protocol*\] \[**-M** *core*\] \[**-N** *system*\] \[**-j** *jail*\] Display per-interface statistics for each network protocol. If both **-i** and **-I** are specified, **-I** overrides any instances of **-i**.

  - **-4**

    Show IPv4 only See GENERAL OPTIONS.

  - **-6**

    Show IPv6 only See GENERAL OPTIONS.

  - **-s**

    If **-s** is repeated, counters with a value of zero are suppressed.

  - **-f** *protocol\_family*

    Filter by *protocol\_family*. See GENERAL OPTIONS.

  - **-p** *protocol*

    Filter by *protocol*. See GENERAL OPTIONS.

  - **-M**

    Use an alternative core See GENERAL OPTIONS.

  - **-N**

    Use an alternative kernel image See GENERAL OPTIONS.

  - **-j** *jail*

    Run inside a jail. See GENERAL OPTIONS.

-

  **netstat** **-m** \[**-M** *core*\] \[**-N** *system*\] \[**-j** *jail*\] Show statistics recorded by the memory management routines ([mbuf(9)](/mbuf/9.md)). The network manages a private pool of memory buffers.

  - **-M**

    Use an alternative core See GENERAL OPTIONS.

  - **-N**

    Use an alternative kernel image See GENERAL OPTIONS.

  - **-j** *jail*

    Run inside a jail. See GENERAL OPTIONS.

-

  **netstat** **-B** \[**-z**\] \[**-I** *interface*\] \[**-j** *jail*\] Show statistics about [bpf(4)](/bpf/4.md) peers. This includes information like how many packets have been matched, dropped and received by the bpf device, also information about current buffer sizes and device states.

  The [bpf(4)](/bpf/4.md) 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 |
  | s | BIOCGSEESENT status: see packets originating locally and |
  | a | Packet reception generates a signal |
  | l | BIOCLOCK status: descriptor has been locked |

-

  **netstat** **-r** \[**-46AnW**\] \[**-F** *fibnum*\] \[**-f** *address\_family*\] \[**-M** *core*\] \[**-N** *system*\] \[**-j** *jail*\] Display the contents of routing tables.

  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)](/route/8.md) and [route(4)](/route/4.md) 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 |

-

  **netstat** **-rs** \[**-s**\] \[**-M** *core*\] \[**-N** *system*\] \[**-j** *jail*\] Display routing statistics.

  - **-s**

    If **-s** is repeated, counters with a value of zero are suppressed.

  - **-M**

    Use an alternative core See GENERAL OPTIONS.

  - **-N**

    Use an alternative kernel image See GENERAL OPTIONS.

  - **-j** *jail*

    Run inside a jail. See GENERAL OPTIONS.

-

  **netstat** **-g** \[**-46W**\] \[**-F** *fibnum*\] \[**-f** *address\_family*\] \[**-M** *core*\] \[**-N** *system*\] \[**-j** *jail*\] Display the contents of the multicast virtual interface tables, and multicast forwarding caches. Entries in these tables will appear only when the kernel is actively forwarding multicast sessions. This option is applicable only to the **inet** and **inet6** address families.

  - **-4**

    Show IPv4 only See GENERAL OPTIONS.

  - **-6**

    Show IPv6 only See GENERAL OPTIONS.

  - **-W**

    Avoid truncating addresses even if this causes some fields to overflow.

  - **-F**

    Display the routing table with the number *fibnum*. If the specified *fibnum* is -1 or **-F** is not specified, the default routing table is displayed.

  - **-f** *protocol\_family*

    Filter by *protocol\_family*. See GENERAL OPTIONS.

  - **-M**

    Use an alternative core See GENERAL OPTIONS.

  - **-N**

    Use an alternative kernel image See GENERAL OPTIONS.

  - **-j** *jail*

    Run inside a jail. See GENERAL OPTIONS.

-

  **netstat** **-gs** \[**-46s**\] \[**-f** *address\_family*\] \[**-M** *core*\] \[**-N** *system*\] \[**-j** *jail*\] Show multicast routing statistics.

  - **-4**

    Show IPv4 only See GENERAL OPTIONS.

  - **-6**

    Show IPv6 only See GENERAL OPTIONS.

  - **-s**

    If **-s** is repeated, counters with a value of zero are suppressed.

  - **-f** *protocol\_family*

    Filter by *protocol\_family*. See GENERAL OPTIONS.

  - **-M**

    Use an alternative core See GENERAL OPTIONS.

  - **-N**

    Use an alternative kernel image See GENERAL OPTIONS.

  - **-j** *jail*

    Run inside a jail. See GENERAL OPTIONS.

-

  **netstat** **-Q** \[**-j** *jail*\] Show [netisr(9)](/netisr/9.md) statistics. The flags field shows available ISR handlers:

  | | | |
  | --- | --- | --- |
  | 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 |
  | **-j** *jail* |

### GENERAL OPTIONS

Some options have the general meaning:

- **-4**

  Is shorthand for **-f** *inet* (Show only IPv4)

- **-6**

  Is shorthand for **-f** *inet6* (Show only IPv6)

- **-f** *address\_family*, **-p** *protocol*

  Limit display to those records of the specified *address\_family* or a single *protocol*. The following address families and protocols are recognized:

  - *Family*

    *Protocols*

  - **inet** (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**

  Extract values associated with the name list from the specified core instead of the default */dev/kmem*.

- **-N**

  Extract the name list from the specified system instead of the default, which is the kernel image the system has booted from.

- **-n**

  Show network addresses and ports as numbers. Normally **netstat** attempts to resolve addresses and ports, and display them symbolically. Specifying **-n** twice will also disable printing the keyword "default" for the default IPv4 and IPv6 routes when displaying contents of routing tables.

- **-W**

  Wider output; expand address fields, etc, to avoid truncation. Non-numeric values such as domain names may still be truncated; use the **-n** option if necessary to avoid ambiguity.

- **-j** *jail*

  Perform the actions inside the *jail*. This allows network state to be accessed even if the **netstat** binary is not available in the *jail*.

## EXAMPLES

Show packet traffic information (packets, bytes, errors, packet drops, etc) for interface re0 updated every 2 seconds and exit after 5 outputs:

```
netstat -w 2 -q 5 -I re0
```

Show statistics for ICMP on any interface:

```
netstat -s -p icmp
```

Show routing tables:

```
netstat -r
```

Same as above, but without resolving numeric addresses and port numbers to names:

```
netstat -rn
```

Show IPv4 listening sockets:

```
netstat -4l
```

## SEE ALSO

[fstat(1)](/fstat/1.md), [nfsstat(1)](/nfsstat/1.md), [procstat(1)](/procstat/1.md), [ps(1)](/ps/1.md), [sockstat(1)](/sockstat/1.md), [libxo(3)](/libxo/3.md), [bpf(4)](/bpf/4.md), [inet(4)](/inet/4.md), [route(4)](/route/4.md), [unix(4)](/unix/4.md), [hosts(5)](/hosts/5.md), [networks(5)](/networks/5.md), [protocols(5)](/protocols/5.md), [services(5)](/services/5.md), [xo\_options(7)](/xo_options/7.md), [iostat(8)](/iostat/8.md), [route(8)](/route/8.md), [vmstat(8)](/vmstat/8.md), [mbuf(9)](/mbuf/9.md)

## HISTORY

The **netstat** command appeared in 4.2BSD.

IPv6 support was added by WIDE/KAME project.

## BUGS

The notion of errors is ill-defined.
