Netstat Command: Uses & Options

The netstat command is used to display network connections, routing tables, and network interface information. It provides a way to monitor active network connections.

Run the netstat command using the following command format.

netstat [options]

Common options for the netstat command include:

  1. – Show the connections and listening ports for all activities.
  2. – Show only TCP connections.
  3. -u: Display only UDP connections.
  4. -n: display the address and port number in numerical form.
  5. -p: Displays the process/program associated with the connection.
  6. -r: Display the routing table.
  7. -s: display network statistics.
  8. Display only listening ports.
  9. -e: display additional information, such as Ethernet frames, MTU, etc.
  10. – c: Continuously display output.

Here are some common examples of the netstat command:

  1. Show all connections and listening ports for activities.
netstat -a
  1. Display only TCP connections.
netstat -t
  1. Show only UDP connections.
netstat -u
  1. Display the address and port number in numeric form.
netstat -n
  1. Display the processes/programs associated with the connection.
netstat -p
  1. Display routing table.
netstat -r
  1. Display network statistics.
netstat -s

Here are some common options and examples for the netstat command. You can choose the appropriate options based on your specific needs when using the netstat command.

bannerAds