-1

Is it correct that

  • if ping host fails, telnet host port will fail too. But not vice versa.

  • i.e. if telnet host port succeeds, ping host will succeed too. But not vice versa.

Thanks.

  • Can you be specific about why wrong? – Tim Aug 21 '18 at 22:59
  • Tim has not in fact asked for any learning materials at all in this question. – JdeBP Aug 22 '18 at 10:40
3

Both facts do not have relation and I fail to see how they are related.

PING/ICMP echo-requests can be ignored at firewall and/or kernel level, and the fact that an host does not answer to pings does not prevent it from answering other services.

Likewise being able to telnet a port, does not implies PING will have to answer.

For an example, try pinging www.iscte.pt and then opening it in a browser, or doing:

$ telnet www.iscte.pt 80
Trying 193.136.188.12...
Connected to www.iscte.pt.
Escape character is '^]'.
GET /
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://www.iscte-iul.pt/">here</a>.</p>
</body></html>
Connection closed by foreign host.

$ ping -c 1 www.iscte.pt
PING www.iscte.pt (193.136.188.12): 56 data bytes
^C
--- www.iscte.pt ping statistics ---
1 packets transmitted, 0 packets received, 100.0% packet loss

You can also have a host that only answers to ping, and all the other reminder services are firewalled and do not answer, or only answer to specific IP addresses.

If the firewall and kernel do not ignore ICMPs, you could also have a server with no services, or with setting at layer 7 that limit services to people with X.509 client certs, or VPN servers or servers with UDP services (DHCP....telnet only tests TCP port services) that do not answer to telnet.

That ignoring if they have an SSH service running; it is highly pratical but not mandatory, or it can only be accessed once inside the VPN, for instance.

see related Does `ping` connect to a ICMP server?

  • Thanks. (1) What is the reason ping in your example doesn't succeed? (2) If firewall and kernel do not ignore ping/icmp requests, will the answers to my two questions be both yes? – Tim Aug 21 '18 at 23:22
  • In this specific example, the server has a sysctl that I talked in the previous answer. It could be that ICMP was firewalled too. If the firewall and kernel do not ignore ICMPs, you could also have a server with no services, or with setting at layer 7 that limit services to people with X.509 client certs, or VPN servers or servers with UDP services (DHCP....) that do not answer to telnet. That ignoring if they have an SSH service running; it is highly pratical but not mandatory. – Rui F Ribeiro Aug 21 '18 at 23:23
  • ICMP is also a lower priority protocol than UDP and TCP, so a busy router may discard ICMP packets altogether, even if there aren't firewall rules in place to block ICMP. – Tim Kennedy Aug 21 '18 at 23:51
  • @TimKennedy A very busy router, but granted, it can and will happen. – Rui F Ribeiro Aug 21 '18 at 23:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.