44

I am trying to ping my website http://www.example.com/ and it resolves to an unknown IP address and times out.

PING http://www.example.com/ (198.105.254.228): 56 data bytes 
Request timeout for icmp_seq 0 
Request timeout for icmp_seq 1 
Request timeout for icmp_seq 2

but when I ping example.com it works

What is it that I'm missing out here?

  • 32
    What's confusing here is that ping shouldn't be even able to resolve that as a hostname, much less send out failed ICMP packets. What OS/version are you on? – fluffy Jun 21 '15 at 8:31
  • 11
    I apologize, but I voted this down because of a combination of reasons - new user with one question that contains a URL to their website with apparently falsified output from PING. By all rights, that's an attempt to drive traffic to the URL. Unless we can find out which operating system has a version of PING that 1) knows what a URL is, and 2) identifies the icmp_seq number for each time out. – Dawn Benton Jun 21 '15 at 15:11
  • 10
  • 25
    To the people who downvoted because they didn't know there are DNS services that hijack failed lookups, didn't know ping and getaddrinfo() and friends pass through slashes, didn't know that 56 data bytes is a common default, etc.: Please take this as a sign that your efforts to learn about things more before trying to help would be appreciated. – rakslice Jun 21 '15 at 20:03
  • 5
    @Ƭᴇcʜιᴇ007 The ping results are real, I see the exact same when I ping an invalid hostname with TimeWarner Cable DNS on OS X. – Hunter Dolan Jun 21 '15 at 21:29
107

I am trying to ping my website http://www.example.com/ and it resolves to an unknown IP address and times out.

PING http://www.example.com/ (198.105.254.228): 56 data bytes
Request timeout for icmp_seq 0

The argument to ping is a hostname (or an IP address).

So the following will all work:

ping example.com
ping www.example.com
ping 127.0.0.1

On the other hand,

ping http://www.example.com/

will not work as http://www.example.com/ is an HTTP Uniform Resource Locator (URL) not a valid hostname (although part of it is a hostname).

A HTTP URL is made up of 4 parts:

  • Scheme — always present
  • Hostname — always present
  • Path or Stem — always present but sometimes is null
  • Parameters — optional

Ping will not normally recognise URLs as a valid destination hostname.

Notes:

  • Not all URLs have the format mentioned above.

  • A complete URL consists of a naming scheme specifier followed by a string whose format is a function of the naming scheme.

  • The format of a URL is defined in the IETF specification Uniform Resource Locators (URL)


DNS Hijacking

An exception to the above can happen if the DNS server (which resolves hostnames to IP addresses) is configured to return a valid IP address even if an invalid hostname is supplied.

This can happen if an ISP is hijacking your DNS queries.

From the answer Why is ping resolving to an IP 198.105.254.228 for any random hostname that i type? by Michael Hampton:

They are trying to be "helpful" by redirecting requests for nonexistent domains to a white label service that provides search results and advertising, from which everyone but you gets a cut of the revenue.

Fortunately they do have a preferences page where you can supposedly turn it off.

32

When you run the ping command with a string that is not an IP address, it first needs to resolve the IP address of the host you are attempting to ping.

When you run:

$ ping example.com

The DNS server returns the IP address of the server that hosts the website.

However when you prefix the protocol and path to create a standard http URL that is all sent to the DNS server to be resolved.

So instead of the DNS server finding the record for example.com it looks for the record http://example.com/ which is not a valid hostname.

A lot of DNS servers will return with nothing. In that case the ping command will just error out with a DNS resolution error.

However your DNS server returns the IP address 123.456.789.000. The address appears to be a suggestion service by Time Warner Cable to help users who mistyped the url in their browser.

But the ping command takes this literally and believes that the hostname http://example.com/ (which is not a valid hostname) resolves to the address 123.456.789.000.

The reason the ping command times out after that is because 123.456.789.000 does not respond to ICMP requests.

  • 5
    It's worth pointing out that the actual domain/ip was edited out by the Community bot."123.456.789.000" was originally the IP address that TWC's DNS threw out when you attempted to resolve a non existent hostname. – Hunter Dolan Jun 21 '15 at 21:25
  • 1
    The bot does not know how to make automatic edits; I would say it is an edit that was suggested by an anonymous user. – Léo Lam Jun 22 '15 at 11:09
  • The edit was proposed by an anonymous user and approved by myself and another user. – DavidPostill Jun 23 '15 at 16:58
20

The http:// stands for hyper text transfer protocol, the protocol used to access web pages. Pinging a server doesn't use HTTP, but instead consists of an ICMP (internet control message protocol) message, so the http:// doesn't make sense in this context.

  • I'd say it's not obvious to someone who doesn't already know, but now that you know the info from KJ4TIP's answer, look at the output: Request timeout for icmp_seq 0 You can see the ICMP there, meaning ICMP sequence 0, 1, 2... – Tyler Collier Jun 21 '15 at 2:03
0

Why would you use 'ping' anyway. It's not going to work if there is a firewall in the way blocking 'ping' traffic.

In my opinion if your going to test a web server then its better to use 'telnet', then you can test the host and the port it should be listening on.

eg: To test your web server telnet www.mywebserver.com 80 at the blank screen, type in 'get' then 'enter' and you should get a pile of http response back from the web server. (eg: HTTP/1.1 400 Bad Request...)

This tells me that not only is the server 'up' but it's also listening and responding on port 80. (I'd also expect any firewalls to let port 80 through to my web server )

Similarly 'telnet' also works for testing mail servers , ftp and just about anything else.

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.