Network Management common Commands (6/14)-netstat command detailed

Source: Internet
Author: User
Tags domain name server

The Netstat command is used to display various network-related information, such as network connections, routing tables, Interface states (Interface Statistics), masquerade connections, multicast members (multicast memberships), and so on.

-A or--all: Displays the socket;-a< network type > or--< network type in all connections;: Lists the relevant addresses in the network type connection;-C or--continuous: Continuously list network status ;-C or--cache: Displays the cache information for the router configuration,-E or--extend: Displays other relevant information about the network;-F or--fib: Show fib;-g or--groups: Displays the multi-broadcast feature group members list;-H or--  Help: online assistance;-I or--interfaces: Displays the Web interface information form;-L or--listening: Displays the Socket;-m or--masquerade of the server in the monitor: shows the spoofed network connection ;-N or--numeric: use the IP address directly, not through the domain name server;-N or--netlink or--symbolic: Displays the symbolic connection name of the network hardware peripheral device;-O or--timers: Display timer ;-P or--programs: shows the program identification code and program name of the socket being used;-R or--route: Display routing table;-s or--statistice: Display network work information statistics ;-T or--tcp: Displays the connection status of the TCP transport protocol;-U or--UDP: Displays the connection status of the UDP transport protocol;-V or--verbose: Displays the instruction execution process;- V or--version: Displays version information; W or--raw: Displays the connection status of the raw transport protocol,-X or--unix: The effect of this parameter is the same as specifying the "-a Unix" parameter,--ip or--inet: The effect of this parameter is the same as specifying the "-a inet" parameter. 
Instance

List all ports (both listening and not listening)

Netstat-a     #列出所有端口netstat-at    #列出所有tcp端口netstat-au    #列出所有udp端口                             

List all Sockets in the listening state

Netstat-l        #只显示监听端口netstat-lt       #只列出所有监听 TCP port netstat-lu       #只列出所有监听 UDP port netstat-lx       #只列出所有监听 UNIX Port

Show statistics for each protocol

Netstat-s   Display statistics for all ports netstat-st   display statistics for TCP ports netstat-su   displays statistics for UDP ports

Show PID and process name in netstat output

Netstat-pt
hosts, ports and usernames (host, port or user) are not displayed in the Netstat output

When you don't want to let the host, port and user name display, use Netstat-n. Numbers will be used instead of those names.

The output can also be accelerated because there is no comparison query.

# Netstat-an

If you just don't want one of these three names to be displayed, use the following command

# netsat-a--numeric-ports
# netsat-a--numeric-hosts
# netsat-a--numeric-users
6. Continuous output of netstat information

Netstat will output network information every second. -C

9. Find out which port the program is running on

Not all processes can be found, no permissions will not be displayed, use root permissions to view all the information.

# Netstat-ap | grep ssh
TCP 1 0 dev-db:ssh 101.174.100.22:39213 close_wait -
TCP 1 0 dev-db:ssh 101.174.100.22:57643 close_wait -

Locate the process running on the specified port

# Netstat-an | grep ': 80 '
10. Display the list of network interfaces
# netstat-i

IP and TCP Analysis

To view the most connected IP addresses for a service port:

Sort-nr

TCP Various status lists:

Netstat-nt | Grep-e 127.0.0.1-e 0.0.0.0-e.:::-V | awk '/^tcp/{++state[$NF]} END {for (I in State) print I, "\ T", state[i]} '

View the number of phpcgi processes, and if they are close to the preset, they are not enough and need to be increased:

Netstat-anpo | grep "wc-l    

Network Management common Commands (6/14)-netstat command detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.