


The netstat command is used to display various network-related information, such as network connections, routing tables, interface status (Interface Statistics), masquerade connections, and multicast memberships (Multicast Memberships) Wait
1 Commonly used options:
-a: (all) displays all options, and does not display LISTEN related ones by default
-t: (tcp) Only display tcp related options
-u: (udp) Only display udp related options
-n: Display IP and port in numbers, can display all numbers Convert to numbers.
-l: List only the service status in Listen (monitoring)
-p: Display the name of the program that establishes the relevant link
-r: Display routing information, Routing table
-e: Display extended information, such as uid, etc.
-s: Statistics based on each protocol
-c: Execute the netstat at regular intervals Order.
-w: raw socket related
2 -tan displays all tcp ports
[root@centos7 ~]# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 52 192.168.29.3:22 192.168.29.1:51029 ESTABLISHED
TCP 0 0 192.168.29.3:22 192.168.29.1:51180 Established
##tcp6 0 0 :::22 :::* LISTENtcp6 0 0 ::1:631 :::* LISTENtcp6 0 0 ::1:25 :::* 3 show all udp ports -uan##[root@centos7 ~]# netstat -anu
Active Internet connections (servers and established)Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 0.0.0.0:5353 0.0.0.0 :*
udp 0 0 0.0.0.0:47414 0.0.0.0:*
udp 0 0 192.168.122.1:53 0.0.0.0:*
udp 0 0 0.0 .0.0:67 0.0.0.0:*
4 Display all listening tcp ports -tnl
##[root@centos7 ~]# netstat -tnl
Active Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0 .0.0:111 0.0.0.0:* LISTENtcp 0 0 192.168.122.1:53 0.0.0.0:* LISTENtcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTENtcp 0 0 127.0.0.1:25 0.0.0.0:* LISTENtcp6 0 0 : ::111 :::* LISTENtcp6 0 0 :::22 :::* LISTENtcp6 0 0 ::1:631 :::* LISTENtcp6 0 0 ::1:25 :::* LISTEN 5 Display all listening udp ports-unl[root@centos7 ~]# netstat -unl
Active Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 0.0.0.0:5353 0.0.0.0:*udp 0 0 0.0.0.0:47414 0.0.0.0:*udp 0 0 0.0.0.0:20815 0.0. 0.0:*udp 0 0 192.168.122.1:53 0.0.0.0:*udp 0 0 0.0.0.0:67 0.0.0.0:*udp 0 0 0.0.0.0:68 0.0.0.0:*udp 0 0 0.0.0.0:68 0.0.0.0:*udp 0 0 0.0.0.0:9804 0.0.0.0:*udp6 0 0 :::12799 :::*udp6 0 0 :::37953 :::* 6 show routing table –rn[root@centos7 ~]# netstat -nr
Kernel IP routing tableDestination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.29.1 0.0.0.0 UG 0 0 0 ens33192.168.29.0 0.0.0.0 255.255.255.0 U 0 0 0 ens33192.168. 122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0[root@centos7 ~]# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface0.0.0.0 192.168.29.1 0.0.0.0 UG 100 0 0 ens33192.168.29.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33192.168. 122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0 7 Display statistics for each protocol(1) Display all ports Statistics netstat -s[root@centos7 ~]# netstat -s
Ip:3808 total packets received
0 forwarded0 incoming packets discarded2444 incoming packets delivered2254 requests sent out32 outgoing packets dropped Icmp:676 ICMP messages received0 input ICMP message failed.ICMP input histogram:destination unreachable: 148
echo replies: 528
717 ICMP messages sent
0 ICMP messages failed
ICMP output histogram:
destination unreachable: 148
echo request: 569
[……]
(2)显示 TCP 端口的统计信息 netstat -st
[root@centos7 ~]# netstat -st
IcmpMsg:
InType0: 528
InType3: 148
OutType3: 148
OutType8: 569
Tcp:
0 active connections openings
2 passive connection openings
0 failed connection attempts
0 connection resets received
2 connections established
1637 segments received
1418 segments send out
0 segments retransmited
0 bad segments received.
0 resets sent
(3)显示 UDP 端口的统计信息 netstat -su
[root@centos7 ~]# netstat -su
IcmpMsg:
InType0: 528
InType3: 148
OutType3: 148
OutType8: 569
Udp:
0 packets received
140 packets to unknown port received.
0 packet receive errors
169 packets sent
0 receive buffer errors
0 send buffer errors
UdpLite:
IpExt:
InMcastPkts: 27
OutMcastPkts: 33
InBcastPkts: 766
InOctets: 410294
OutOctets: 432666
InMcastOctets: 4963
OutMcastOctets: 5444
InBcastOctets: 179503
InNoECTPkts: 3848
8 显示 PID 和进程名称 netstat -p
[root@centos7 ~]# netstat -p
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 52 centos7.3.local:ssh gateway:51029 ESTABLISHED 1552/sshd: root@pts
tcp 0 0 centos7.3.local:ssh gateway:51180 ESTABLISHED 1854/sshd: root@pts
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ] DGRAM 8520 1/systemd /run/systemd/notify
unix 2 [ ] DGRAM 8522 1/systemd /run/systemd/cgroups-agent
unix 5 [ ] DGRAM 8542 1/systemd /run/systemd/journal/socket
unix 28 [ ] DGRAM 8544 1/systemd /dev/log
unix 2 [ ] DGRAM 11419 1/systemd /run/systemd/shutdownd
unix 3 [ ] STREAM CONNECTED 23993 1276/ibus-x11
The above is the detailed content of What is the netstat command? How to use netstat command?. For more information, please follow other related articles on the PHP Chinese website!

This article discusses how to improve Hadoop data processing efficiency on Debian systems. Optimization strategies cover hardware upgrades, operating system parameter adjustments, Hadoop configuration modifications, and the use of efficient algorithms and tools. 1. Hardware resource strengthening ensures that all nodes have consistent hardware configurations, especially paying attention to CPU, memory and network equipment performance. Choosing high-performance hardware components is essential to improve overall processing speed. 2. Operating system tunes file descriptors and network connections: Modify the /etc/security/limits.conf file to increase the upper limit of file descriptors and network connections allowed to be opened at the same time by the system. JVM parameter adjustment: Adjust in hadoop-env.sh file

This guide will guide you to learn how to use Syslog in Debian systems. Syslog is a key service in Linux systems for logging system and application log messages. It helps administrators monitor and analyze system activity to quickly identify and resolve problems. 1. Basic knowledge of Syslog The core functions of Syslog include: centrally collecting and managing log messages; supporting multiple log output formats and target locations (such as files or networks); providing real-time log viewing and filtering functions. 2. Install and configure Syslog (using Rsyslog) The Debian system uses Rsyslog by default. You can install it with the following command: sudoaptupdatesud

When choosing a Hadoop version suitable for Debian system, the following key factors need to be considered: 1. Stability and long-term support: For users who pursue stability and security, it is recommended to choose a Debian stable version, such as Debian11 (Bullseye). This version has been fully tested and has a support cycle of up to five years, which can ensure the stable operation of the system. 2. Package update speed: If you need to use the latest Hadoop features and features, you can consider Debian's unstable version (Sid). However, it should be noted that unstable versions may have compatibility issues and stability risks. 3. Community support and resources: Debian has huge community support, which can provide rich documentation and

This article describes how to use TigerVNC to share files on Debian systems. You need to install the TigerVNC server first and then configure it. 1. Install the TigerVNC server and open the terminal. Update the software package list: sudoaptupdate to install TigerVNC server: sudoaptinstalltigervnc-standalone-servertigervnc-common 2. Configure TigerVNC server to set VNC server password: vncpasswd Start VNC server: vncserver:1-localhostno

Configuring a Debian mail server's firewall is an important step in ensuring server security. The following are several commonly used firewall configuration methods, including the use of iptables and firewalld. Use iptables to configure firewall to install iptables (if not already installed): sudoapt-getupdatesudoapt-getinstalliptablesView current iptables rules: sudoiptables-L configuration

The steps to install an SSL certificate on the Debian mail server are as follows: 1. Install the OpenSSL toolkit First, make sure that the OpenSSL toolkit is already installed on your system. If not installed, you can use the following command to install: sudoapt-getupdatesudoapt-getinstallopenssl2. Generate private key and certificate request Next, use OpenSSL to generate a 2048-bit RSA private key and a certificate request (CSR): openss

Configuring a virtual host for mail servers on a Debian system usually involves installing and configuring mail server software (such as Postfix, Exim, etc.) rather than Apache HTTPServer, because Apache is mainly used for web server functions. The following are the basic steps for configuring a mail server virtual host: Install Postfix Mail Server Update System Package: sudoaptupdatesudoaptupgrade Install Postfix: sudoapt

To configure the DNS settings for the Debian mail server, you can follow these steps: Open the network configuration file: Use a text editor (such as vi or nano) to open the network configuration file /etc/network/interfaces. sudonano/etc/network/interfaces Find network interface configuration: Find the network interface to be modified in the configuration file. Normally, the configuration of the Ethernet interface is located in the ifeth0 block.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use