Use netcat instead of telnet

Network engineers often use telnet to establish a connection to a service on a remote server. Apple dropped the telnet and ftp client in macOS High Sierra. First I was very disappointed, but realistically telnet is history.

Instead of trying solutions to get telnet back, look forward and start using netcat.

Connect to a webserver and get the headers:

nc -v www.microsoft.com 80

Then type your GET request for / with a minimal  host header.

GET / HTTP/1.1 [enter]
Host: example.com [enter]

and you get the result

Connection to www.microsoft.com port 80 [tcp/http] succeeded!
GET / HTTP/1.1
Host: www.example.com
HTTP/1.1 503 Service Unavailable
Server: AkamaiGHost
Mime-Version: 1.0
Content-Type: text/html
Content-Length: 268
Expires: Sun, 18 Feb 2018 15:09:36 GMT
Date: Sun, 18 Feb 2018 15:09:36 GMT
Connection: keep-alive
<HTML><HEAD>
<TITLE>Service Unavailable</TITLE>
</HEAD><BODY>
<H1>Service Unavailable - DNS failure</H1>
The server is temporarily unable to service your request.  Please try again later.<P>
Reference&#32;&#35;11&#46;7efa6d68&#46;1518966576&#46;17cd556
</BODY></HTML>

This method can be used for all ports. You can also get the headers for mail servers, ssh servers.

If you only want to know if the port is open, simply use:

nc -vz www.microsoft.com 80

You can also use netcat to verify if  UDP ports are open:

nc -vz -u 8.8.8.8 53

And netcat can be used as a port scanner:

nc -vz <hostname or ip address> 1-1000