Introduction
Telnet is a command line utility that can be used to test the connectivity of a specific port.
Procedure
Telnet is provided by most operating systems and can be installed using your operating systems package manager:
Ubuntu
apt install telnet
CentOS 7
yum install telnet
CentOS 8 or AlmaLinux
dnf install telnet
Telnet accepts an IP or host along with a port. If the connection is blocked, you will get either a connection refused or a timeout.
[root@host ~]# telnet example.tld 25
telnet: connect to address 192.168.1.1: Connection refused
[root@host ~]# telnet host.example.tld 25
telnet example.tld 25
telnet: connect to address 10.0.0.1: Connection timed out
If the connection is successful, telnet will say connected and potentially return output in the below example, port 25 was used, so the SMTP banner returns:
[root@host ~]# telnet host.example.tld 25
Connected to host.example.tld.
Escape character is '^]'.
220-host.example.tld ESMTP Exim 4.95 #2 Wed, 11 Jan 2023 12:40:54 +0000
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
Telnet will use the system's primary IP address by default. You can use the -b flag to test telnet connections from a specific IP address on your server. This is useful if you are sending mail from a different IP address:
[root@host ~]# telnet -b 10.0.0.1 host.example.tld 25
Connected to host.example.tld.
Escape character is '^]'.
220-host.example.tld ESMTP Exim 4.95 #2 Wed, 11 Jan 2023 12:40:54 +0000
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
To exit a telnet session, use the CTRL+] keyboard combination, hit enter, then type close and hit enter again:
[root@host ~]# telnet host.example.tld 25
Connected to host.example.tld.
Escape character is '^]'.
220-host.example.tld ESMTP Exim 4.95 #2 Wed, 11 Jan 2023 12:40:54 +0000
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
^]
telnet> close
Connection closed.
Comments
0 comments
Article is closed for comments.