View the listening port on netstat in CentOS

Source: Internet
Author: User
Tags to domain

View the listening port on netstat in CentOS
[Root @ pa137 ~] # Netstat -- help
Usage: netstat [-veenNcCF] [<Af>]-r netstat {-V | -- version |-h | -- help}
Netstat [-vnNcaeol] [<Socket>...]
Netstat {[-veenNac]-I [<Iface>] | [-veenNac]-I | [-cnNe]-M |-s} [delay]


-R, -- route display routing table
-I, -- interfaces = [<Iface>] display interface table for <Iface>
-I, -- interfaces display interface table
-G, -- groups display multicast group memberships
-S, -- statistics display networking statistics (like SNMP)
-M, -- masquerade display masqueraded connections


-V, -- verbose be verbose
-N, -- numeric don't resolve names
-- Numeric-hosts don't resolve host names
-- Numeric-ports don't resolve port names
-- Numeric-users don't resolve user names
-N, -- symbolic resolve hardware names
-E, -- extend display other/more information
-P, -- programs display PID/Program name for sockets
-C, -- continuous listing


-L, -- listening display listening server sockets
-A, -- all, -- listening display all sockets (default: connected)
-O, -- timers display timers
-F, -- fib display Forwarding Information Base (default)
-C, -- cache display routing cache instead of FIB
-T, -- notrim stop trimming long addresses
-Z, -- context display SELinux security context for sockets


<Iface>: Name of interface to monitor/list.
<Socket >={-t | -- tcp} {-u | -- udp} {-S | -- sctp} {-w | -- raw} {-x | -- unix }-- ax25 -- ipx -- netrom
<AF> = Use '-A <af>' or '-- <af>'; default: inet
List of possible address families (which support routing ):
Inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25)
Netrom (ampr net/ROM) ipx (Novell IPX) ddp (Appletalk DDP)

X25 (CCITT X.25)

Display the tcp port being listened on:

-L indicates the listener.

-T indicates tcp

-P indicates the display program name

-N indicates that the Department converts ip addresses and ports to domain names and service names.

-Utable udp

[Root @ pa137 ~] # Netstat-tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
Tcp 0 0 0.0.0.0: 111 0.0.0.0: * LISTEN 2493/portmap
Tcp 0 0 127.0.0.1: 631 0.0.0.0: * LISTEN 2776/cupsd
Tcp 0 0 127.0.0.1: 25 0.0.0.0: * LISTEN 2808/sendmail: acce
Tcp 0 0 0.0.0.0: 1020 0.0.0.0: * LISTEN 2534/rpc. statd
Tcp 0 0: 3306: * LISTEN 15681/mysqld
Tcp 0 0: 22: * LISTEN 2767/sshd

[Root @ pa137 ~] #

[Root @ pa137 ~] # Netstat-atnp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
Tcp 0 0 0.0.0.0: 111 0.0.0.0: * LISTEN 2493/portmap
Tcp 0 0 127.0.0.1: 631 0.0.0.0: * LISTEN 2776/cupsd
Tcp 0 0 127.0.0.1: 25 0.0.0.0: * LISTEN 2808/sendmail: acce
Tcp 0 0 0.0.0.0: 1020 0.0.0.0: * LISTEN 2534/rpc. statd
Tcp 0 0: 3306: * LISTEN 15681/mysqld
Tcp 0 0: 22: * LISTEN 2767/sshd
Tcp 0 0: ffff: 192.168.1.0000: 22: ffff: 192.168.31.101: 49223 ESTABLISHED 3110/2
Tcp 0 260: ffff: 192.168.1.0000: 22: ffff: 192.168.31.101: 49712 ESTABLISHED 3438/4
Tcp 0 0: ffff: 192.168.1.0000: 22: ffff: 192.168.31.102: 1039 ESTABLISHED 3151/3
[Root @ pa137 ~] # Netstat-aunp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
Udp 0 0 0.0.0.0: 33716 0.0.0.0: * 2915/avahi-daemon:
Udp 0 0 0.0.0.0: 5353 0.0.0.0: * 2915/avahi-daemon:
Udp 0 0 0.0.0.0: 111 0.0.0.0: * 2493/portmap
Udp 0 0 0.0.0.0: 1014 0.0.0.0: * 2534/rpc. statd
Udp 0 0 0.0.0.0: 631 0.0.0.0: * 2776/cupsd
Udp 0 0 0.0.0.0: 1017 0.0.0.0: * 2534/rpc. statd
Udp 0 0: 5353: * 2915/avahi-daemon:
Udp 0 0: 54269: * 2915/avahi-daemon:
[Root @ pa137 ~] #

Function Description: Netstat is used to display statistics related to IP, TCP, UDP, and ICMP protocols. It is generally used to check the network connection of each port on the local machine.
Syntax: netstat [-acCeFghilMnNoprstuvVwx] [-A <network type>] [-- ip]
Note: The netstat command allows you to know the network conditions of the entire Linux system.
Parameters:
-A or-all shows the sockets in all connections.
-A <network type> or-<network type> lists the related addresses of the network type connections.
-C or-continuous continuously lists the network status.
-C or-cache displays the cache information of the vro configuration.
-E or-extend displays other network-related information.
-F or-fib displays FIB.
-G or-groups displays a list of members of the Multi-Broadcast Function Group.
-H or-help online help.
-I or-interfaces displays the network interface information form.
-L or-listening displays the Socket of the monitored server.
-M or-masquerade displays disguised network connections.
-N or-numeric directly uses the IP address instead of the Domain Name Server.
-N or-netlink or-symbolic indicates the symbolic connection name of the network hardware peripheral device.
-O or-timers displays the timer.
-P or-programs shows the program identification code and program name using Socket.
-R or-route displays the Routing Table.
-S or-statistice displays a statistical table of network work information.
-T or-tcp shows the connection status of the TCP transmission protocol.
-U or-udp shows the connection status of UDP transmission protocol.
-V or-verbose displays the command execution process.
-V or-version displays version information.
-W or-raw shows the RAW transmission protocol connection status.
-X or-unix: this parameter has the same effect as the specified "-A unix" parameter.
-Ip or-inet: the effect of this parameter is the same as that of the specified "-A inet" parameter.

Some common netstat options

· Netstat-s

This option displays statistical data for each protocol. If our applications (such as Web browsers) run slowly or cannot display data such as Web pages, we can use this option to view the displayed information. We need to carefully check the rows of statistics, find the keyword of the error, and then determine the problem.

· Netstat-e

This option is used to display statistics about Ethernet. It lists items including the total number of bytes, number of errors, number of delimiters, number of datagram, and number of broadcasts. These statistics include both the number of sent and received data packets. This option can be used to calculate some basic network traffic ).

· Netstat-r

This option displays information about the route table, similar to the information shown later when you use the route print command. In addition to valid routes, valid connections are also displayed.

· Netstat-

This option displays a list of all valid connections, including ESTABLISHED connections (ESTABLISHED) and LISTENING connections.

· Netstat-n

All established valid connections are displayed.

Related Article

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.