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

0

1

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

Nav

Posted 2014-08-26T12:47:10.163

Reputation: 913

No route to host ... might be crucial. – Hennes – 2014-08-26T14:07:13.993

1but I'm able to connect using ssh – Nav – 2014-08-26T14:20:18.173

Can you dump the routing table of the CentOS client and the RHEL server? ip route – Nicolas – 2014-08-26T14:36:39.120

@Nicolas: updated my question with the dump info – Nav – 2014-08-27T03:08:16.463

Answers

2

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

Nicolas

Posted 2014-08-26T12:47:10.163

Reputation: 358

A firewall problem it was. Solved. Thanks! :) And sorry, the IP was 192.18.212.124. I had earlier temporarily connected to the 209 subnet for testing. – Nav – 2014-08-27T11:03:34.013

0

Both the CentOS client and the RHEL server are in the 192.18.209.x segment. According to your route dumps, the default gateway on CentOS is 192.12.209.3, while the default gateway on RHEL is 192.12.212.3.

Try to change the default gateway on RHEL in 192.12.209.3 and check if it works.

user3767013

Posted 2014-08-26T12:47:10.163

Reputation: 1 297

I agree, but note that the Windows system is 212 and still isn't able to connect. I was able to connect from RHEL to a switch at 192.18.209.111 because in the switch configuration I changed the security setting to allow the RHEL telnet client to connect to the switch. Is there any way to tell the RHEL telnet server to allow other systems to connect to it? I'm able to connect to localhost on the RHEL system. – Nav – 2014-08-27T08:20:57.887

I had even connected the RHEL system to the 209 subnet, where it got a different IP of 192.18.209.17 but I still wasn't able to connect to it using Telnet, but ssh worked as usual. – Nav – 2014-08-27T08:33:22.610

Just to verify: you can SSH from 192.18.212.169 to 192.18.209.124, but Telnet fails? What if you enter "telnet 192.18.209.124 22", can the Windows computer reach the SSH-port with telnet? – user3767013 – 2014-08-27T09:42:26.590

Sorry, it's actually 192.18.212.124. I got it confused after I had connected it to 209, for trying out a different possibility. When trying telnet 192.18.209.124 22, the command prompt just shows SSH-2.0-OpenSSH_5.3 and remains stuck at that – Nav – 2014-08-27T10:55:32.390

Problem is solved anyway. It was a firewall problem. – Nav – 2014-08-27T11:04:05.193