Commands to Test Port Connectivity from a MID Server Host to a Remote TargetSummary<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } When troubleshooting issues for Discovery, Service Mapping, Orchestration, JDBC/LDAP, 3rd Party Integrations, or any other application that uses a MID Server to connect to a remote target, we may need to test if the MID Server's Host is able to make TCP Connection to the target device. Sometimes we open an RDP or SSH Connection to the host and run the default telnet command to test for open ports only to find out that telnet isn't installed or enabled on the MID Server's host. The purpose of this article is to list alternate commands that are more likely to be installed on the MID Server's host and can be used to test port connectivity in place of telnet. The commands listed here can be run on the MID Server's host through a direct remote connection.These commands can also be executed from the instance by creating an ECC Queue 'Command' probe to be run locally on the MID Server's host without the need to RDP/SSH into it. Release<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } All Instructions<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } Table of Contents I. Commands to Test Port Connectivity Windows Linux/UNIX II. Run a Port Connectivity Command remotely through a MID Server's hosting device directly from the ECC Queue with a Command probe.III. Quick Reference List of Commands I. Commands to Test Port Connectivity Windows 1. Test-NetConnection Syntax: Test-NetConnection -ComputerName <ip_address_here> -Port <port_number_here> • Test-NetConnection and the -ComputerName parameter have default aliases that can be used to shorten the length of the command. tnc -cn <ip_address_here> -Port <port_number_here> • Test-NetConnection can also be run from the Windows CMD Prompt by executing powershell.exe before the command. powershell "Test-NetConnection -ComputerName <ip_address_here> -Port <port_number_here>" Successful Connection Failed Connection Linux/UNIX 1. nc TCP Syntax: nc -z -v -w <timeout_in_seconds> <ip_address> <port_number> • The nc command can be used to test connectivity to either TCP Port or a UDP Port Successful TCP Connection: user@localhost:~ $ nc -z -v -w 5 192.168.0.10 80 Connection to 192.168.0.10 80 port [tcp/http] succeeded! Failed TCP Connections: user@localhost:~ $ nc -z -v -w 5 192.168.0.3 24 nc: connect to 192.168.0.3 port 24 (tcp) failed: Connection refused user@localhost:~ $ nc -z -v -w 5 192.168.0.10 8090 nc: connect to 192.168.0.10 port 8090 (tcp) timed out: Operation now in progress UDP Syntax: nc -z -v -u -w <timeout_in_seconds> <ip_address> <port_number> || echo "Connection Failed" Successful UDP Connection: user@localhost:~ $ nc -z -v -u -w 5 192.168.0.3 161 Connection to 192.168.0.3 161 port [udp/snmp] succeeded! Failed UDP Connection: user@localhost:~ $ nc -z -v -u -w 5 192.168.0.3 24 user@localhost:~ $ Connection Failed 2. curl Syntax: curl -v -t "- TCP=TEST" --connect-timeout <timeout_in_seconds> telnet://<ip_address>:<port_number> < /dev/null Successful Connection: user@localhost:~ $ curl -v -t "- TCP=TEST" --connect-timeout 10 telnet://192.168.0.10:80 < /dev/null * Trying 192.168.0.10:80... * Connected to 192.168.0.10 (192.168.0.10) port 80 * Closing connection Failed Connection: user@localhost:~ $ curl -v -t "- TCP=TEST" --connect-timeout 10 telnet://192.168.0.10:5 < /dev/null * Trying 192.168.0.10:5... * ipv4 connect timeout after 9998ms, move on! * Failed to connect to 192.168.0.10 port 5 after 10004 ms: Timeout was reached * Closing connection curl: (28) Failed to connect to 192.168.0.10 port 5 after 10004 ms: Timeout was reached 3. wget Syntax: wget -v --tries 1 --timeout 5 ftp://<ip_address>:<port_number> > /dev/null Successful Connection: user@localhost:~ $ wget -v --tries 1 --timeout 5 ftp://192.168.0.3:22 > /dev/null --2023-01-14 11:45:40-- ftp://192.168.0.3:22/ => ‘.listing’ Connecting to 192.168.0.3:22... connected. Error in server response. Closing. Giving up. Failed Connection: user@localhost:~ $ wget -v --tries 1 --timeout 5 ftp://192.168.0.3:24 > /dev/null --2023-01-14 11:47:10-- ftp://192.168.0.3:24/ => ‘.listing’ Connecting to 192.168.0.3:24... failed: Connection refused. 4. telnet Syntax: timeout <timeout_in_seconds> telnet <ip_address> <port_number> Successful Connection: user@localhost:~ $ timeout 10 telnet 192.168.0.10 80 Trying 192.168.0.10... Connected to 192.168.0.10. Escape character is '^]'. Failed Connection: user@localhost:~ $ timeout 10 telnet 192.168.0.10 5 Trying 192.168.0.10... II. Run a Port Connectivity Command remotely through a MID Server's hosting device directly from the ECC Queue with a Command probe. Any of the above commands can be run directly from the instance by creating a Command probe to be executed on the MID Server's host locally. Procedure 1. Navigate to the ECC Queue and click New. 2. Create a message with these settings: Agent: The name of the MID Server that executes the command.Topic: CommandName: The actual command that you want to process. For Windows, this is expressed in a DOS command line structure. For Linux, the structure could be a bash command line entry.Queue: Output 3. Save the record 4. Refresh the Queues related list at the bottom of the record until the ECC Queue Input is returned. 5. Open the ECC Queue Input record and check the results. III. Quick Reference List of Commands Windows Server TCP Port Connection Test Commands: Powershell • Test-NetConnection -ComputerName <ip_address_here> -Port <port_number_here> Command Prompt (CMD) • powershell "Test-NetConnection -ComputerName <ip_address_here> -Port <port_number_here>" Linux/UNIX Server TCP Port Connection Test Commands: • nc -z -v -w <timeout_in_seconds> <ip_address> <port_number> • curl -v telnet://<ip_address_here>:<port_number_here> • wget -v --tries 1 --timeout 5 ftp://<ip_address_here>:<port_number_here> > /dev/null • timeout <timeout_in_seconds> telnet <ip_address> <port_number> Linux/UNIX Server UDP Port Connection Test Commands: • nc -z -v -u -w <timeout_in_seconds> <ip_address> <port_number> || echo "Connection Failed"