10 basic usages of the netstat command

Source: Internet
Author: User

What is netstat?

Netstat is a command-line tool that lists all network socket connections on the system, including TCP, UDP, and UNIX sockets, and it can also list sockets that are in a listening state (that is, waiting for an access request).
If you want to confirm that the WEB service on the system has not been up, you can see if port 80 has not been opened. How do I use netstat to find network connection information and system-enabled port numbers?

Netstat-print network connections, routing tables, connected data statistics, spoofed connections, and broadcast domain members.

1. List all connections
netstat  -a         列出 tcp, udp 和 unix 协议下所有套接字的所有连接。
2. List only connections for TCP or UDP protocols
netstat -at         使用 -t 选项列出 TCP 协议的连接    netstat -au        使用 -u 选项列出 UDP 协议的连接
3. Disable reverse Domain name resolution to speed up query
 netstat -ant 默认情况下 netstat 会通过反向域名解析技术查找每个 IP 地址对应的主机名。   这会降低查找速度,如果你觉得 IP 地址已经足够,而没有必要知道主机名,就使用 -n 选项禁用域名解析功能。
4. List only the connections in the listener
 netstat  -tnl    查看TCP端口中监听的连接 netstat -unl   查看 UDP 端口中监听的连接
5. Get the process name, process number, and user ID
netstat -nlpt         使用 -p选项查看进程信息。

When viewing port and connection information, it is very helpful for system administrators to be able to see their corresponding process names and process numbers.

6. Print statistical data
 netstat -s   可以打印出网络统计数据,包括某个协议下的收发包数量。
7. Displaying kernel routing information
 netstat -rn  使用 -r 选项打印内核路由信息。打印出来的信息与 route 命令输出的信息一样。-n 选项禁止域名解析。
8. Print network interface
 netstat -i    打印网络接口信息 netstat -ie  将 -e 选项和 -i 选项搭配使用,输出信息与 ifconfig 输出的信息一样。
9.netstat Continuous output
 netstat -ct    显示持续输出信息
10. Displaying multicast group information
  netstat -g    选项 -g 会输出 IPv4 和 IPv6 的多播组信息。

10 basic usages of the netstat command

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.