search cancel

How can I verify port communications outside of telnet?

book

Article ID: 239707

calendar_today

Updated On:

Products

Workload Automation Agent CA Workload Automation AE CA Workload Automation AE - Business Agents (AutoSys) CA Workload Automation AE - Scheduler (AutoSys) CA Workload Automation AE - System Agent (AutoSys) CA Workload Automation DE CA Workload Automation DE - Business Agents (dSeries) CA Workload Automation DE - Scheduler (dSeries) CA Workload Automation DE - System Agent (dSeries)

Issue/Introduction

The telnet command is disabled by security policy. Is there another command based utility that we can use to test port communications?

Environment

Release : 12.0

Component : Workload Automation System Agent

Resolution

There are a number of ways that one can test network communications to validate port connectivity.

  • Option 1 - (Linux only) Requires the nc package to be installed. This can be done through yum install. (yum install nc)
    Command syntax: nc -zv <host_name_or_ip> <port>

    Example of a successful connection:
    [[email protected] tmp]# nc -zv lvnkprod014236.bpc.broadcom.net 7523
    Ncat: Version 7.70 ( https://nmap.org/ncat )
    Ncat: Connected to <IP_MASKED>:7523.
    Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.

    Example of a failed connection:
    [[email protected] 12.3]# nc -zv lvnkprod014236.bpc.broadcom.net 7523
    Ncat: Version 7.70 ( https://nmap.org/ncat )
    Ncat: Connection refused.

  • Option 2 - (Any OS) Requires the curl package to be installed. (On Linux, yum install curl)
    Command syntax: curl -v telnet://hostname:8443

    Example of a successful connection:
    [[email protected] tmp]# curl -v telnet://lvnkprod014236.bpc.broadcom.net:7523
    * Rebuilt URL to: telnet://lvnkprod014236.bpc.broadcom.net:7523/
    *   Trying <IP_MASKED>...
    * TCP_NODELAY set
    * Connected to lvnkprod014236.bpc.broadcom.net (IP_MASKED) port 7523 (#0)

    Example of a failed connection:
    [[email protected] 12.3]# curl -v telnet://lvnkprod014236.bpc.broadcom.net:7523
    * Rebuilt URL to: telnet://lvnkprod014236.bpc.broadcom.net:7523/
    *   Trying <IP_MASKED>..
    * TCP_NODELAY set
    * connect to <IP_MASKED> port 7523 failed: Connection refused
    * Failed to connect to lvnkprod014236.bpc.broadcom.net port 7523: Connection refused
    * Closing connection 0
    curl: (7) Failed to connect to lvnkprod014236.bpc.broadcom.net port 7523: Connection refused



  • Option 3 - (Linux or UNIX only) Use cat /dev/tcp
    Command syntax: cat </dev/null >/dev/tcp/1.2.3.4/7163; echo $?
    This will return a value of either 0 or 1, with 0 being successful and 1 being failed.

    Example of successful connection:
    [[email protected] tmp]# cat </dev/null >/dev/tcp/lvnkprod014236.bpc.broadcom.net/7523; echo $?
    0
    Example of failed connection:
    [[email protected] tmp]# cat </dev/null >/dev/tcp/lvnkprod014236.bpc.broadcom.net/7523; echo $?
    1

  • Option 4: (Windows only) Use Powershell.
    Command Syntax: Test-NetConnection -ComputerName lvnkprod014236.bpc.broadcom.net -port 7523

    Example of successful connection:
    PS C:\Users\Administrator> Test-NetConnection -ComputerName lvnkprod014236.bpc.broadcom.net -port 7523
    C
    omputerName     : lvnkprod014236.bpc.broadcom.net
    RemoteAddress    : <IP_MASKED>
    RemotePort       : 7523
    InterfaceAlias   : tap7b3834e0-f5
    SourceAddress    : <IP_MASKED>
    TcpTestSucceeded : True

    Example of failed connection:
    PS C:\Users\Administrator> Test-NetConnection -ComputerName lvnkprod014236.bpc.broadcom.net -port 7523

    WARNING: TCP connect to (<IP_MASKED> : 7523) failed


    ComputerName           : lvnkprod014236.bpc.broadcom.net
    RemoteAddress          : <IP_MASKED>
    RemotePort             : 7523
    InterfaceAlias         : tap7b3834e0-f5
    SourceAddress          : <IP_MASKED>
    PingSucceeded          : True
    PingReplyDetails (RTT) : 1 ms
    TcpTestSucceeded       : False