YouTip LogoYouTip

Linux Comm Netstat

Image 1: Linux Complete command reference Linux Complete command reference\\n\\n

Linux netstat Command used to display network status.

\\n

The netstat command allows you to know the network status of the entire Linux system.

\\n\\n

Syntax

\\n
netstat [-A<Network type>]
\\n

Parameter description:

\\n
    \\n
  • -aor--all Display all connected sockets.
  • \\n
  • -A<Network type>or--<Network type> List the relevant addresses in connections of this Network type.
  • \\n
  • -cor--continuous Continuously list network status.
  • \\n
  • -Cor--cache Display router configuration cache information.
  • \\n
  • -eor--extend Display other network related information.
  • \\n
  • -For--fib Display routing cache.
  • \\n
  • -gor--groups Display multicast group member list.
  • \\n
  • -hor--help Online help.
  • \\n
  • -ior--interfaces Display network interface information form.
  • \\n
  • -lor--listening Display sockets of monitored servers.
  • \\n
  • -Mor--masquerade Display masqueraded network connections.
  • \\n
  • -nor--numeric Use IP addresses directly, bypassing DNS.
  • \\n
  • -Nor--netlinkor--symbolic Display symbolic link names of network hardware peripherals.
  • \\n
  • -oor--timers Display timers.
  • \\n
  • -por--programs Display PID and program name of processes using sockets.
  • \\n
  • -ror--route Display Routing Table.
  • \\n
  • -sor--statistics Display network statistics table.
  • \\n
  • -tor--tcp Display TCP connection status.
  • \\n
  • -uor--udp Display UDP connection status.
  • \\n
  • -vor--verbose Display command execution process.
  • \\n
  • -Vor--version Display version information.
  • \\n
  • -wor--raw Display RAW protocol connection status.
  • \\n
  • -xor--unix The effect of this parameter is the same as specifying"-A unix"Same parameters.
  • \\n
  • --ipor--inet The effect of this parameter is the same as specifying"-A inet"Same parameters.
  • \\n
\\n\\n

Example

\\n

Display detailed network status.

\\n
# netstat -a
\\n

Display current active UDP connection status

\\n
# netstat -nu
\\n

Display UDP port usage

\\n
# netstat -apu\\nActive Internet connections (servers and established)\\nProto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name\\nudp        0      0 *:32768                 *:*                     -\\nudp        0      0 *:nfs                   *:*                     -\\nudp        0      0 *:641                   *:*                     3006/rpc.statd\\nudp        0      0 192.168.0.3:netbios-ns   *:*                     3537/nmbd\\nudp        0      0 *:netbios-ns            *:*                     3537/nmbd\\nudp        0      0 192.168.0.3:netbios-dgm  *:*                     3537/nmbd\\nudp        0      0 *:netbios-dgm           *:*                     3537/nmbd\\nudp        0      0 *:tftp                  *:*                     3346/xinetd\\nudp        0      0 *:999                   *:*                     3366/rpc.rquotad\\nudp        0      0 *:sunrpc                *:*                     2986/portmap\\nudp        0      0 *:ipp                   *:*                     6938/cupsd\\nudp        0      0 *:1022                  *:*                     3392/rpc.mountd\\nudp        0      0 *:638                   *:*                     3006/rpc.statd
\\n

Display network interface list

\\n
# netstat -i\\nKernel Interface table\\nIface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg\\neth0       1500  0     181864      0      0      0     141278      0      0      0 BMRU\\nlo        16436  0       3362      0      0      0       3362      0      0      0 LRU
\\n

Display multicast group relationships.

\\n
# netstat -g\\nIPv6/IPv4 Group Memberships\\nInterface       RefCnt Group\\n--------------- ------ ---------------------\\nlo              1      ALL-SYSTEMS.MCAST.NET\\neth0            1      ALL-SYSTEMS.MCAST.NET\\nlo              1      ff02::1\\neth0            1      ff02::1:ff0a:b0c\\neth0            1      ff02::1
\\n

Display network statistics

\\n
# netstat -s\\nIp:\\n    184695 total packets received\\n    0 forwarded\\n    0 incoming packets discarded\\n    184687 incoming packets delivered\\n    143917 requests sent out\\n    32 outgoing packets dropped\\n    30 dropped because of missing route\\nIcmp:\\n    676 ICMP messages received\\n    5 input ICMP message failed.\\n    ICMP input histogram:\\n        destination unreachable: 44\\n        echo requests: 287\\n        echo replies: 345\\n    304 ICMP messages sent\\n    0 ICMP messages failed\\n    ICMP output histogram:\\n        destination unreachable: 17\\n        echo replies: 287\\nTcp:\\n    473 active connections openings\\n    28 passive connection openings\\n    4 failed connection attempts\\n    11 connection resets received\\n    1 connections established\\n    178253 segments received\\n    137936 segments send out\\n    29 segments retransmited\\n    0 bad segments received.\\n    336 resets sent\\nUdp:\\n    5714 packets received\\n    8 packets to unknown port received.\\n    0 packet receive errors\\n    5419 packets sent\\nTcpExt:\\n    1 resets received for embryonic SYN_RECV sockets\\n    ArpFilter: 0\\n    12 TCP sockets finished time wait in fast timer\\n    572 delayed acks sent\\n    3 delayed acks further delayed because of locked socket\\n    13766 packets directly queued to recvmsg prequeue.\\n    1101482 packets directly received from backlog\\n    19599861 packets directly received from prequeue\\n    46860 packets header predicted\\n    14541 packets header predicted and directly queued to user\\n    TCPPureAcks: 12259\\n    TCPHPAcks: 9119\\n    TCPRenoRecovery: 0\\n    TCPSackRecovery: 0\\n    TCPSACKReneging: 0\\n    TCPFACKReorder: 0\\n    TCPSACKReorder: 0\\n    TCPRenoReorder: 0\\n    TCPTSReorder: 0\\n    TCPFullUndo: 0\\n    TCPPartialUndo: 0\\n    TCPDSACKUndo: 0\\n    TCPLossUndo: 0\\n    TCPLoss: 0\\n    TCPLostRetransmit: 0\\n    TCPRenoFailures: 0\\n    TCPSackFailures: 0\\n    TCPLossFailures: 0\\n    TCPFastRetrans: 0\\n    TCPForwardRetrans: 0\\n    TCPSlowStartRetrans: 0\\n    TCPTimeouts: 29\\n    TCPRenoRecoveryFail: 0\\n    TCPSackRecoveryFail: 0\\n    TCPSchedulerFailed: 0\\n    TCPRcvCollapsed: 0\\n    TCPDSACKOldSent: 0\\n    TCPDSACKOfoSent: 0\\n    TCPDSACKRecv: 0\\n    TCPDSACKOfoRecv: 0\\n    TCPAbortOnSyn: 0\\n    TCPAbortOnData: 1\\n    TCPAbortOnClose: 0\\n    TCPAbortOnMemory: 0\\n    TCPAbortOnTimeout: 3\\n    TCPAbortOnLinger: 0\\n    TCPAbortFailed: 3\\n    TCPMemoryPressures: 0
\\n

Display listening sockets.

\\n
# netstat -l\\nActive Internet connections (only servers)\\nProto Recv-Q Send-Q Local Address           Foreign Address         State\\ntcp        0      0 *:32769                 *:*                     LISTEN\\ntcp        0      0 *:nfs                   *:*                     LISTEN\\ntcp        0      0 *:644                   *:*                     LISTEN\\ntcp        0      0 *:1002                  *:*                     LISTEN\\ntcp        0      0 *:netbios-ssn           *:*                     LISTEN\\ntcp        0      0 *:sunrpc                *:*                     LISTEN\\ntcp        0      0 vm-dev:ipp              *:*                     LISTEN\\ntcp        0      0 *:telnet                *:*                     LISTEN\\ntcp        0      0 *:601                   *:*                     LISTEN\\ntcp        0      0 *:microsoft-ds          *:*                     LISTEN\\ntcp        0      0 *:http                  *:*                     LISTEN\\ntcp        0      0 *:ssh                   *:*                     LISTEN\\ntcp        0      0 *:https                 *:*                     LISTEN\\nudp        0      0 *:32768                 *:*\\nudp        0      0 *:nfs                   *:*\\nudp        0      0 *:641                   *:*\\nudp        0      0 192.168.0.3:netbios-ns   *:*\\nudp        0      0 *:netbios-ns            *:*\\nudp        0      0 192.168.0.3:netbios-dgm  *:*\\nudp        0      0 *:netbios-dgm           *:*\\nudp        0      0 *:tftp                  *:*\\nudp        0      0 *:999                   *:*\\nudp        0      0 *:sunrpc                *:*\\nudp        0      0 *:ipp                   *:*\\nudp        0      0 *:1022                  *:*\\nudp        0      0 *:638                   *:*\\nActive UNIX domain sockets (only servers)\\nProto RefCnt Flags       Type       State         I-Node Path\\nunix  2           STREAM     LISTENING     10621  @/tmp/fam-root-\\nunix  2           STREAM     LISTENING     7096   /var/run/acpid.socket\\nunix  2           STREAM     LISTENING     9792   /tmp/.gdm_socket\\nunix  2           STREAM     LISTENING     9927   /tmp/.X11-unix/X0\\nunix  2           STREAM     LISTENING     10489  /tmp/ssh-lbUnUf4552/agent.4552\\nunix  2           STREAM     LISTENING     10558  /tmp/ksocket-root/kdeinit__0\\nunix  2           STREAM     LISTENING     10560  /tmp/ksocket-root/kdeinit-:0\\nunix  2           STREAM     LISTENING     10570  /tmp/.ICE-unix/dcop4664-1270815442\\nunix  2           STREAM     LISTENING     10843  /tmp/.ICE-unix/4735\\nunix  2           STREAM     LISTENING     10591  /tmp/ksocket-root/klauncherah3arc.slave-socket\\nunix  2           STREAM     LISTENING     7763   /var/run/iiim/.iiimp-unix/9010\\nunix  2           STREAM     LISTENING     11047  /tmp/orbit-root/linc-1291-0-1e92c8082411\\nunix  2           STREAM     LISTENING     11053  /tmp/orbit-root/linc-128e-0-dc070659cbb3\\nunix  2           STREAM     LISTENING     8020   /var/run/dbus/system_bus_socket\\nunix  2           STREAM     LISTENING     58927  /tmp/mcop-root/vm-dev-2c28-4beba75f\\nunix  2           STREAM     LISTENING     7860   /tmp/.font-unix/fs7100\\nunix  2           STREAM     LISTENING     7658   /dev/gpmctl\\nunix  2           STREAM     LISTENING     10498  @/tmp/dbus-s2MLJGO5Ci
\\n\\nImage 2: Linux Complete command reference Linux Complete command reference
← Linux Comm PingLinux Comm Wall β†’