Question
How do you use telnet to troubleshoot connectivity issues on a port?
Answer
Install telnet if it's not already installed. The command to install it depends on the server's operating system:
# yum install telnet
# dnf install telnet
# apt 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.
# telnet domain.tld 25
telnet: connect to address 192.168.1.1: Connection refused
# telnet host.domain.tld 25
telnet domain.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:
# telnet host.domain.tld 25
Connected to host.domain.tld.
Escape character is '^]'.
220-host.domain.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:
# telnet -b 10.0.0.1 host.domain.tld 25
Connected to host.domain.tld.
Escape character is '^]'.
220-host.domain.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:
# telnet host.domain.tld 25
Connected to host.domain.tld.
Escape character is '^]'.
220-host.domain.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.