I don't want to go far in to details, because I know you should not use telnet but ssh instead, however in my situation I need to use telnet.

Basically, I have a Ubuntu server 18.04.1 and I have a web page hosted on it. The web page is specifically for configuring routers and sending them commands through telnet(it is a django site, and commands are sent by python's telnetlib). The problem is, I need to telnet using the telnet's default port 23.

I have checked that telnet is installed and I checked that I can telnet, for example, telnet google.com 80 works, however if I write telnet ip_of_router 23 I get this output.

telnet: Unable to connect to remote host: No route to host

Next thing I tried was to open port 23, both through sudo ufw allow 23 and using iptables: sudo iptables -A OUTPUT -p tcp --dport telnet -j ACCEPT. No success.

What else I need to do so I can telnet ip_of_router 23?

I have added a listener to port 23 like this: sudo nc -lk 23 & and checked with netcat client if port 23 is open: nc -v localhost 23.

It outputted: nc: connect to localhost port 23 (tcp) failed: Connection refused. Connection to localhost 23 port [tcp/telnet] succeeded!

To my understanding it should have outputted one of them not both.

How can I telnet from Ubuntu server to another host using port 23? I am new to Linux, so any help is appreciated.

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         _gateway         UG    0      0        0 ens32
Server_Ip   U     0      0        0 ens32
  • I suspect nc -v -z <ip-of-router> 23 will also give you a "No route to host" error. Can you ping <ip-of-router>? I suspect that there is a firewall (or at least a gateway of some kind) between you and the router you're trying to reach. – Daniel Pryden Nov 2 '18 at 11:55
  • Note particularly that you don't need to be listening on port 23 to be able to connect to port 23 on another machine. You probably don't want to leave the port open on your machine, just ensure that your local firewall is not blocking outbound traffic to port 23, particularly port 23 of your target machine(s). (Blocking inbound traffic to port 23 on your computer is perfectly fine and shouldn't be relevant for this problem.) – Daniel Pryden Nov 2 '18 at 11:57
  • About the first comment, nc -v -z <ip-of-router> 23 gives the same error. I can ping the server, even if firewall (ufw) is enabled or disabled. I allowed outbound traffic using the commands mentioned in question, however I don't know why it is not working. – alzagars Nov 2 '18 at 12:20
  • It's odd that nc gives you "No route to host" but ping works. What does route show? – Daniel Pryden Nov 2 '18 at 12:27
  • Added in question – alzagars Nov 2 '18 at 12:31

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.