Networking – Telnet: Could not open connection to the host on port 23 : connect failed

networkingtelnet

I've Googled it a lot and checked it on many forums, but still haven't been able to solve it.

When I do a telnet from a Windows system 192.18.212.169 to an RHEL system on 192.18.212.124 I get the error

Connecting To 192.18.212.124…Could not open connection to the host,
on port 23 : Connect failed.

When I try from a CentOS system 192.18.209.87 I get the error

Trying 192.18.212.124… telnet: connect to address 192.18.212.124: No
route to host

The telnet server and client have been installed on 192.18.212.124 and I'm able to login to a switch from 192.18.209.124 once I allowed it's subnet on the switch.

But when I try to connect to 192.18.212.124 from any other system, it doesn't work. Although if I try connecting using ssh from any system, it works.

I know telnet is old, but it's required for a particular software I'm using. Please help.

Update:
ip route for the CentOS client (192.18.209.87):

default via 192.18.209.3 dev enp1s0 proto static metric
1024
192.18.200.80 via 192.18.209.3 dev enp1s0 proto static metric 1
192.18.209.0/24 dev enp1s0 proto kernel scope link src 192.18.209.87
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1

ip route of RHEL server (192.18.212.124):

192.18.212.0/24 dev eth2 proto kernel scope link src 192.18.212.124 metric 1
default via 192.18.212.3 dev eth2 proto static

Best Answer

Given that ssh works but telnet doesn't, there are a few options:

  • A firewall is blocking the traffic on the server
  • Telnet is not running on the server
  • Your connections are routed through a gateway that filters out telnet traffic
  • You typed different ip addresses when you tried to connect via ssh / telnet

1. It could be your server's firewall that's blocking the connection.

As a quick check, add (temporary) rules to allow all the traffic:

[root@server]# iptables -I INPUT 1 -j ACCEPT
[root@server]# iptables -I OUTPUT 1 -j ACCEPT

You might as well do the same on the client to get that out of the way. When you're done testing (at the end of this message), remove these two with

[root@server]# iptables -D INPUT 1
[root@server]# iptables -D OUTPUT 1

2. Your server is missing a route for its 192.18.209.0/24 (?) subnet

Your server's routing table is weird. You said its IP address was 192.18.209.124, but the routing table says it's 192.18.212.124 . Did you change it to the 212 subnet to test some things? If so, can you revert it back to the state it was when you wrote your first message?

Do traceroutes from the server to the client and vice versa to check the paths are correct.

3. Full testing sequence, ONLY if you have a physical access to the server (as you might lose network access due to the potential ip change)

Assuming your topology is a very simple one with both machines on the same network as on the following diagram:

        +---------+                  Server: 192.18.209.124/24
        | Switch  |                  CentOS: 192.18.209.87 /24
        +---------+
     _____|     |_____
    |                 |
+--------+        +--------+
| Server |        | CentOS |
+--------+        +--------+

[root@server] iptables -I INPUT 1 -j ACCEPT
[root@server] iptables -I OUTPUT 1 -j ACCEPT
[root@server] ifconfig eth2 192.18.209.124/24
[root@server] netstat -tapn | grep :23

[root@centos] iptables -I INPUT 1 -j ACCEPT
[root@centos] iptables -I OUTPUT 1 -j ACCEPT
[root@centos] traceroute 192.18.209.124
[root@centos] nc -vv 192.18.209.124 23

[root@server] traceroute 192.18.209.87
[root@server] iptables -D INPUT 1
[root@server] iptables -D OUTPUT 1

[root@centos] iptables -D INPUT 1
[root@centos] iptables -D OUTPUT 1
Related Question