Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.
Notice: I'm taking a break from blogging to focus on Atari Gamer . com, check it out!

When macOS High Sierra (10.13) was released, the telnet utility disappeared. This has probably been a good move by Apple since telnet is outdated and not a secure protocol; it shouldn't be used in general. However, telnet did serve a useful function - checking if it was possible to connect to a remote server on a particular port. Luckily there is a much better tool for this included in macOS - nc (netcat).
nc.png


Using nc is simple and it has command line arguments that are very similar to telnet. I like to use the -vz arguments whenever I need to check if a remote server can be reached on a particular port. These arguments make nc have this behaviour...
-v Have nc give more verbose output.
-z Specifies that nc should just scan for listening daemons, without sending any data to them.


The result is nc tries to connect to the server and then immediately terminates if it succeeds. Here's an example...
 nc output
> nc -vz 10.xxx.xxx.xx0 7002
found 0 associations
found 1 connections:
1: flags=82<CONNECTED,PREFERRED>
outif en0
src 192.168.xxx.xxx port 61731
dst 10.xxx.xxx.xx0 port 7002
rank info not available
TCP aux info available
Connection to 10.xxx.xxx.xx0 port 7002 [tcp/afs3-prserver] succeeded!




If a connection cannot be established and a timeout is reached the output is like this (timeout can be controlled via the -G option i.e. -G 5)...
 nc output
> nc -vz 10.xxx.xxx.xx0 9443
nc: connectx to 10.xxx.xxx.xx0 port 9443 (tcp) failed: Operation timed out


If a connection is refused, the output is like this...
 nc output
> nc -vz 10.xxx.xxx.xx1 7002
nc: connectx to 10.xxx.xxx.xx1 port 7002 (tcp) failed: Connection refused


-i

A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. If you spot something out of place, please do let me know.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.