Coder's Cat

Basic Networking tool: telnet

2020-03-09

Basic Networking tools: Telnet

file:img/CAPTURE-2020_03_09_basic-networking-tools.org_20200309_115418.png

telnet maybe the most basic networking tool in Unix/Linux. It’s developed in 1969 with RFC15.

Telnet uses a client-server protocol, which is a reliable connection-oriented protocol.

Currently, almost nobody uses telnet server, but we still use telnet to establish TCP connection to a server.

Test whether a port is opened and connectivity is OK

Suppose you start a server, but you don’t know whether everything is OK, then run telnet like this:

telnet [domainname or ip] [port]

If you connected successfully, the output will be like this:

file:img/CAPTURE-2020_03_09_basic-networking-tools.org_20200309_112637.png

Otherwise, the connectivity is not OK, the output will be:

file:img/CAPTURE-2020_03_09_basic-networking-tools.org_20200309_112916.png

The reason may be: Operation timed out、Connection refused。

Send an HTTP request

Since telnet establishes a TCP connection, and also could be used to send an HTTP request to server.

For instance, we execute command line telnet coderscat.com 80, then we input the following text (Note there are four lines, including 2 empty lines):

GET / HTTP/1.1
Host: coderscat.com


We get a valid HTTP response with status code 301 (redirect to HTTPS).

file:img/CAPTURE-2020_03_09_basic-networking-tools.org_20200309_113457.png

Connect to a Redis server

We could use telnet to connect a Redis server and execute some redis operations:

./img/telnet-to-redis.gif

Telnet’s limitation

telnet can not function as a server, and can not using UDP protocol.

Join my Email List for more insights, It's Free!😋