Netstat view the ports that are listening

Source: Internet
Author: User
Tags extend domain name server to domain
[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=[&LT;IFACE&GT;] 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 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


&LT;IFACE&GT: Name of interface to Monitor/list.
&LT;SOCKET&GT;={-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)

Displays the TCP port that is listening:

-L means listening

-T indicates TCP

-P indicates that the program name is displayed

-N represents the conversion of IP and port to domain names and service names

-U represents 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:: £ º::* 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:: £ º::* LISTEN 2767/sshd
TCP 0 0:: ffff:192.168.1.137:22:: ffff:192.168.31.101:49223 established 3110/2
TCP 0:: ffff:192.168.1.137:22:: ffff:192.168.31.101:49712 established 3438/4
TCP 0 0:: ffff:192.168.1.137: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 Note: Netstat is used to display statistics related to IP, TCP, UDP, and ICMP protocols, which are generally used to verify the network connectivity of the local ports.
Syntax: netstat [-accefghilmnnoprstuvvwx][-a< network type >][--IP]
Supplemental Note: Use the NETSTAT directive to let you know the entire Linux system network situation.
Parameters
A or –all displays the sockets in all lines.
-a< network type > or –< network type > lists the related addresses in the network type line.
The-C or –continuous continues to list network status.
-C or –cache displays the router configuration's cache information.
-E or –extend displays other information about the network.
-F or –fib display fib.
A-G or –groups displays a list of multiple broadcast feature group members.
-H or –help online Help.
-I or –interfaces display the network interface information form.
-L or –listening displays the socket for the server in the monitor.
-M or –masquerade displays a disguised 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 peripherals.
The timer is displayed in-O or –timers.
-P or –programs displays the program identifier and program name that are using the socket.
-R or –route displays routing Table.
-S or –statistice Display network work Information tab.
-T or –TCP displays the connection status of the TCP transport protocol.
-U or –UDP displays the connection status of the UDP transport protocol.
The-V or –verbose displays the instruction execution process.
-V or –version display 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 the specified "-A unix" parameter.
–ip or –inet The effect of this parameter is the same as the specified "-A inet" parameter

Some common options for netstat

Netstat–s

This option displays its statistics separately according to each protocol. If our application, such as a Web browser, runs slowly or cannot display data such as a Web page, then we can use this option to view the information displayed. We need to look closely at the lines of the statistics, find the keywords that are wrong, and then identify the problem.

netstat–e

This option is used to display statistics about Ethernet. The items listed include the total number of bytes, errors, deletes, number of datagrams, and number of broadcasts for the transmitted datagram. These statistics include both the number of datagrams sent and the number of datagrams received. This option can be used to count some basic network traffic.

Netstat–r

This option displays information about the routing table, similar to the information you see later when you use the route Print command. In addition to displaying a valid route, the currently active connection is displayed.

Netstat–a

This option displays a list of all valid connection information, including established connections (established), and those connections that listen for connections (listening).

Netstat–n

Displays all valid connections that have been established.

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.