Check if a port on a remote system is reachable (without telnet)
February 4, 2019 2 Comments
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
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
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