Netstat examples of important and careful review

Source: Internet
Author: User

Example

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

netstat -pCan be used in conjunction with other switches, you can add "Pid/process name" to the netstat output, so debugging can easily find a specific port to run the program.

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

When you do not 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-portsnetsat-a--numeric-hostsnetsat-a--numeric-users

Continuous output netstat information

Netstat-c   #每隔一秒输出网络信息

Show address families not supported by the system (addr families)

Netstat--verbose

At the end of the output, the following information is available:

Netstat:no support for ' AF-IPX ' on the ' system.netstat:no support for ' AF AX25 ' on this system.netstat:no AF X25 ' on the System.netstat:no support for ' AF Netrom ' on the This system.

Show Core Routing information

Netstat-r

Use netstat -rn the display number format without querying the host name.

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.

Ssh

Locate the process running on the specified port:

Netstat-an | grep ': 80 '

Show list of network interfaces

Netstat-i

Displays detailed information, such as ifconfig use netstat -ie .

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

Netstat examples of important and careful review

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.