Netstat SOCKets/-s report

Displays information for open TCP and/or UDP sockets associated with a client name.

Restriction: This command displays socket information only for sockets that are bound to a port or an IP address. TCP connections that have been shutdown or aborted are not displayed.

TSO syntax

Read syntax diagramSkip visual syntax diagram
>>---NETSTAT SOCKets--| Target |--| Output |--| (Filter |------><

Target

Provide the report for a specific TCP/IP address space by using TCp tcpname. See The Netstat command target for more information about the TCp parameter.

Output

The default output option displays the output on the user's terminal. For other options, see The TSO NETSTAT command syntax or Netstat command output.

Filter

Read syntax diagramSkip visual syntax diagram
             .----------------.            
             V                |            
>>-+-CLIent------clientname---+--------+-----------------------><
   +-HOSTName--hostname----------------+   
   |         .-----------------------. |   
   |         V                       | |   
   +-IPAddr----+-ipaddr------------+-+-+   
   |           +-ipaddr/prefixLen--+   |   
   |           '-ipaddr/subnetmask-'   |   
   |         .----------------.        |   
   |         V                |        |   
   +-IPPort----ipaddr+portnum-+--------+   
   +-NOTN3270--------------------------+   
   |       .-------------.             |   
   |       V             |             |   
   '-POrt------portnum---+-------------'   

z/OS UNIX syntax

Read syntax diagramSkip visual syntax diagram
>>---netstat -s--| Target |--| Output |--| Filter |------------><

Target

Provide the report for a specific TCP/IP address space by using -p tcpname. See The Netstat command target for more information about the TCp parameter.

Output

The default output option displays the output to z/OS UNIX shell stdout. For other options, see The z/OS UNIX netstat command syntax or Netstat command output.

Filter

Read syntax diagramSkip visual syntax diagram
          .----------------.            
          V                |            
>>-+- -B----ipaddr+portnum-+--------+--------------------------><
   |      .----------------.        |   
   |      V                |        |   
   +- -E------clientname---+--------+   
   +- -H--hostname------------------+   
   |      .-----------------------. |   
   |      V                       | |   
   +- -I----+-ipaddr------------+-+-+   
   |        +-ipaddr/prefixLen--+   |   
   |        '-ipaddr/subnetmask-'   |   
   |      .-------------.           |   
   |      V             |           |   
   +- -P------portnum---+-----------+   
   '- -T----------------------------'   

Filter description

CLIent/-E clientname
Filter the output of the SOCKets/-s report using the specified client name clientname. You can enter up to six filter values and each specified value can be up to eight characters long.
HOSTName/-H hostname
Filter the output of the SOCKets/-s report using the specified host name hostname. You can enter one filter value at a time and the specified value can be up to 255 characters long.

Result: At the end of the report, Netstat will display the host name that the resolver used for the resolution and the list of IP addresses returned from the resolver that it used as filters.

Restrictions:
  1. The HOSTName/-H filter does not support wildcard characters.
  2. Using the HOSTName/-H filter might cause delays in the output due to resolution of the hostname value, depending upon resolver and DNS configuration.
IPAddr/-I ipaddrIPAddr/-I ipaddr/prefixlengthIPAddr/-I ipaddr/subnetmask
Filter the report output using the specified IP address ipaddr, ipaddr/prefixlength, or ipaddr/subnetmask. You can enter up to six filter values. Each specified IPv4 ipaddr value can be up to 15 characters in length and each selected IPv6 ipaddr value can be up to 45 characters in length.
ipaddr
Filter the output of the SOCKets/-s report using the specified IP address ipaddr. For IPv4 addresses, the default subnet mask of 255.255.255.255 is used. For IPv6 addresses, the default prefixlength of 128 is used.
ipaddr/prefixlength
Filter the output of the SOCKets/-s report using the specified IP address and prefix length ipaddr/prefixlength. For an IPv4 address, the prefix length range is 1 – 32. For an IPv6 address, the prefix length range is 1 – 128.
ipaddr/subnetmask
Filter the output of the SOCKets/-s report using the specified IP address and subnet mask ipaddr/subnetmask. The IP address ipaddr in this format must be an IPv4 IP address.
Guidelines:
  1. The filter value ipaddr can be an address to which the socket is bound or connected.
  2. For an IPv6-enabled stack:
    • Both IPv4 and IPv6 ipaddr values are accepted and can be mixed on the IPAddr/-I option.
    • An IPv4-mapped IPv6 address is accepted as a valid ipaddr value and will usually provide the same result as its IPv4 address does.
Restrictions:
  1. The filter value for an IPv6 address does not support wildcard characters.
  2. For an IPv4-only stack, only IPv4 ipaddr values are accepted.
  3. For a UDP endpoint socket, the filter value applies only to the local or source IP address.
IPPort/-B ipaddr+portnum
Filter the report output of the SOCKets/-s report using the specified IP address and port number. You can enter up to six filter values. Each specified IPv4 ipaddr value can be up to 15 characters in length, denoting a single IPv4 IP address; each specified IPv6 ipaddr value can be up to 45 characters in length, denoting a single IPv6 IP address. Valid portnum values are in the range 0 – 65535. The filter values ipaddr and portnum will match any combination of the local and remote IP address and local and remote port.
Guidelines:
  • The filter value ipaddr can be either the local or remote IP address.
  • For an IPv6-enabled stack, the following apply:
    • Both IPv4 and IPv6 ipaddr values are accepted and can be mixed on the IPPort/-B option.
    • An IPv4-mapped IPv6 address is accepted as a valid ipaddr value and usually provides the same result as the IPv4 address.
Restrictions:
  • The ipaddr value in the IPPort/-B filter does not support wildcard characters.
  • For an IPv4-only stack, only IPv4 ipaddr values are accepted.
  • An entry is returned only when both the ipaddr and portnum values match.
  • For a UDP endpoint socket, the filter value applies only to the local or source IP address and port.
NOTN3270/-T
Filter the output of the SOCKets/-s report, excluding TN3270 server connections.
POrt/-P portnum
Filter the output of the SOCKets/-s report using the specified port number portnum. You can enter up to six filter values.

Guideline: The port number can be a port to which the socket is bound or connected.

Restriction: For a UDP endpoint socket, the filter value applies only to the local or source port.

The filter value for CLIent/-E and IPAddr/-I can be a complete string or a partial string using wildcard characters. A wildcard character can be an asterisk (*), which matches a null string or any character or character string, at the same position. A wildcard character can be a question mark (?), which matches any single character at the same position. For example, a string "searchee" matches with "*ar?he*", but the string "searhee" does not match with "*ar?he*". If you want to use the wildcard character on the IPAddr/-I filter, you must specify the value in the ipaddr format. The wildcard character is not accepted for the ipaddr/prefixlen or ipaddr/subnetmask format of IPAddr/-I values.

When you use z/OS UNIX netstat/onetstat command in a z/OS UNIX shell environment, take care if you use a z/OS UNIX MVS™ special character in a character string. It might cause an unpredictable result. To be safe, if you want to use a z/OS UNIX MVS special character in a character string, surround the character string with single (') or double (") quotation marks. For example, to use an asterisk (*) in the IP address, 10.*.0.0 for the -I filter, issue the command as: netstat -s -I '10.*.0.0' or netstat -s -I "10.*.0.0".

Command syntax examples

From TSO environment

NETSTAT SOCKETS
   Display information about each client using the socket interface in the default 
   TCP/IP stack. 
NETSTAT SOCKETS TCP TCPCS6
   Display information about each client using the socket interface in TCPCS6 stack.
NETSTAT SOCKETS TCP TCPCS8 (IPADDR 9.43.1.1 9.43.2.2
   Display information for these clients using the socket interface in TCPCS8 stack 
   whose IP addresses to which the socket is bound or connected match the specified 
   filter IP address values.
NETSTAT SOCKETS (PORT 2222 6666 88
   Display information for those active TCP connections and UDP sockets in the 
   default TCP/IP stack whose port numbers to which the socket is bound or connected 
   match the specified filter port numbers.

From UNIX shell environment

   netstat -s
   netstat -s -p tcpcs6 
   netstat -s -p tcpcs6 -I 9.43.1.1 9.43.2.2
   netstat -s -P 2222 6666 88

Report examples

The following examples are generated by using TSO NETSTAT command. Using the z/OS UNIX netstat command displays the data in the same format as the TSO NETSTAT command.

Not IPv6 enabled (SHORT format)

NETSTAT SOCKETS
MVS TCP/IP NETSTAT CS V2R1       TCPIP NAME: TCPCS            17:40:36  
Sockets interface status:                                              
Type   Bound to               Connected to           State    Conn     
====   ========               ============           =====    ====     
Name: FTPD1     Subtask: 007E6408                                      
Stream 0.0.0.0..21            0.0.0.0..0             Listen   0000003B 
Stream 9.37.65.146..21        9.67.115.5..1026       Establsh 0000003D 
Stream 9.37.65.146..21        9.27.13.21..3711       Establsh 0000003F 
Name: SYSLOGD1  Subtask: 007E6408                                      
Dgram  0.0.0.0..514           *..*                   UDP      00000010 
Name: TAPPV4    Subtask: 007E6460                                      
Dgram  0.0.0.0..2049          9.42.103.99..1234      UDP      00000015

Name: TCPCS     Subtask: 007E2A40                                      
Stream 0.0.0.0..23            0.0.0.0..0             Listen   0000000F 
Name: TCPCS     Subtask: 007E08D0                                      
Stream 9.67.115.5..23         9.27.11.182..4886      Establsh 0000000C 

IPv6 enabled or request for LONG format

NETSTAT SOCKETS
MVS TCP/IP NETSTAT CS V2R1       TCPIP NAME: TCPCS            17:40:36  
Sockets interface status:                                              
Name: FTPD1     Subtask: 007E6330                                      
  Type: Stream  Status:  Listen    Conn: 0000004A                      
    BoundTo: ::..21                                                    
    ConnTo:  ::..0                                                     
  Type: Stream  Status:  Establsh  Conn: 00000052                      
    BoundTo: ::ffff:9.67.115.5..21                                     
    ConnTo:  ::ffff:9.67.115.65..1026                                  
  Type: Stream  Status:  Establsh  Conn: 00000058                      
    BoundTo: 2001:0db8::9:67:115:66..21                                
    ConnTo:  2001:0db8::9:67:115:65..1027                              
Name: SYSLOGD1  Subtask: 007E6438                       
  Type: Dgram   Status:  UDP       Conn: 0000002C       
    BoundTo: 0.0.0.0..529                               
    ConnTo:  *..*                                       
Name: TAPPV4    Subtask: 007E6460                       
  Type: Dgram   Status:  UDP       Conn: 00000015       
    BoundTo: 0.0.0.0..2049                               
    ConnTo:  9.42.103.99..1234
Name: TAPPV6    Subtask: 007E6480                       
  Type: Dgram   Status:  UDP       Conn: 00000016       
    BoundTo: ::..2050                               
    ConnTo:  12ab::1..1235

Name: TCPCS     Subtask: 007E1930                       
  Type: Stream  Status:  Listen    Conn: 0000001A       
    BoundTo: 0.0.0.0..23                                
    ConnTo:  0.0.0.0..0                                 
  Type: Stream  Status:  Establsh  Conn: 0000001E       
    BoundTo: 9.67.115.5..23                             
    ConnTo:  9.27.11.182..4665                          
Name: USER3     Subtask: 007B93D0                       
  Type: Stream  Status:  Establsh  Conn: 0000005F       
    BoundTo: 2001:0db8::9:67:115:5..1079                
    ConnTo:  2001:0db8::9:67:115:65..21                 
Name: USER6     Subtask: 007B93F0                       
  Type: Stream  Status:  Establsh  Conn: 000000C7       
    BoundTo: 9.67.115.5..1027                           
    ConnTo:  9.37.65.146..21   

Report field descriptions

The following list shows the information displayed after invoking the SOCKets parameter:
Name
The client address space name.
Subtask
The subtask identifier indicates the task that created the socket or issued a bind socket API call for the socket. This identifier is the hexadecimal address of the Task Control Block (TCB) associated with this task. The subtask identifier is combined with the address space name to produce a unique identifier for the client.
Type
Displays the socket type and can have one of the following values:
Stream
Socket type for stream (TCP) sockets.
Dgram
Socket type for UDP sockets.
Bound to
Indicates the address and port to which the socket is bound. The output is in the format IP address..bound port where IP address is the address to which the socket is bound and bound port is the port number to which the socket is bound. Unbound TCP and UDP sockets are not displayed by NETSTAT CONN.
Connected to
Displays the address and port to which the socket is connected. For UDP sockets, the value of this field is *..* if the socket is not connected. For connected UDP sockets, this field shows the remote IP address and port specified on the connect request. When a UDP socket is connected, it accepts packets only from the specified remote IP address and port.
State
Describes the state of the TCP connection. See TCP connection status for more information.
Conn
Displays the client identifier, which is a unique number assigned by the TCP/UDP stack to uniquely identify a socket entity.