Check if a port on a remote system is reachable (without telnet)

Problem:

I wanted to check if our customer had an issue with network access. I asked him to run telnet command, but because of their security reasons, telnet rpm was not installed at all.

Solution:

One of the solution would be to run nc 🙂 but of course nc was not installed. 🙂

The following command helped me in that situation:

cat < /dev/tcp/192.168.3.4/3260

The port is open if there is no output, but if you receive the following, then the port is closed:

-bash: connect: Connection refused
-bash: /dev/tcp/192.168.3.4/3261: Connection refused

 

Advertisement

About Mariami Kupatadze
Oracle Certified Master Linkedin: https://www.linkedin.com/in/mariami-kupatadze-01074722/

2 Responses to Check if a port on a remote system is reachable (without telnet)

  1. zhwsh says:

    that is easy.
    my test it take me 60s.

    $ date ;cat /dev/tcp/192.168.100.40/1521
    $ echo $?
    0
    $ echo a > /dev/tcp/192.168.100.40/1522
    -bash: connect: Connection refused
    -bash: /dev/tcp/192.168.100.40/1522: Connection refused
    –//it is fast.

    I find about INBOUND_CONNECT_TIMEOUT parameter,modfy INBOUND_CONNECT_TIMEOUT:

    $ grep INBOUND_CONNECT_TIMEOUT sqlnet.ora listener.ora
    sqlnet.ora:SQLNET.INBOUND_CONNECT_TIMEOUT=30
    listener.ora:INBOUND_CONNECT_TIMEOUT_LISTENER=2

    $ date ;cat < /dev/tcp/192.168.100.40/1521;date
    Mon Feb 11 10:24:43 CST 2019
    Mon Feb 11 10:24:45 CST 2019

  2. zhwsh says:

    that is easy.
    my test it take me 60s.

    $ date ;cat comment to avoid WordPress format
    Mon Feb 11 10:22:25 CST 2019
    Mon Feb 11 10:23:25 CST 2019

    –//modify and run:
    $ echo a > /dev/tcp/192.168.100.40/1521
    $ echo $?
    0
    $ echo a > /dev/tcp/192.168.100.40/1522
    -bash: connect: Connection refused
    -bash: /dev/tcp/192.168.100.40/1522: Connection refused
    –//it is fast.

    I find about INBOUND_CONNECT_TIMEOUT parameter,modfy INBOUND_CONNECT_TIMEOUT:

    $ grep INBOUND_CONNECT_TIMEOUT sqlnet.ora listener.ora
    sqlnet.ora:SQLNET.INBOUND_CONNECT_TIMEOUT=30
    listener.ora:INBOUND_CONNECT_TIMEOUT_LISTENER=2

    $ date ;cat comment to avoid WordPress format
    Mon Feb 11 10:24:43 CST 2019
    Mon Feb 11 10:24:45 CST 2019

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: