Thread: DNS resolver gives an IP that ISN'T the domain's?

  1. #1
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158

    Exclamation DNS resolver gives an IP that ISN'T the domain's?

    I've been working on my own DNS resolver lately (for education purposes), and I just encountered a weird thing...

    My resolver, and two other online resolvers (DNS <-> IP converter and Web Based DNS Lookup (NSLookup) (ZoneEdit.com)) are coming to the same conclusions (which should make be think that my resolver is working) on this.

    www.google.com -> 74.125.127.104
    cboard.cprogramming.com -> 76.74.255.245

    But if you look at both Google links, and both C Board links, you'll see that they are in fact, not the same thing. What in the world?

    What do you think is happening here?

  2. #2
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Oh yes, and the ping utility comes to the same conclusions too.
    Something else that all 4 resolvers do, is map cboard.cprogramming.com and www.cprogramming.com to the same IP.
    Yet, for some reason, besides all this weirdness, my browser is able to navigate just fine! (It stinks that FF won't show you the IP of the page your at, so I could compare.)

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    I do not understand what you are complaining for.

    if you put the google ip into the browser you get the google site, so on that ip the google web-site is really hosted...
    google itself could redirect you to another ip that is closer to your location...

    with the cboard - on the same ip could be hosted several domains... what is your problem with it?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  4. #4
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    The server that is hosting CProgramming is configured to support multiple domain names, therefore it doesn't show CProgramming site when you enter the IP address.

    Are you wondering how the server knows which domain you are requesting even though the client resolves the domain name before sending the request? It's pretty simple actually - the domain name is included in the HTTP headers.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by vart View Post
    with the cboard - on the same ip could be hosted several domains... what is your problem with it?
    Yeah, you can set up apache to serve "virtual domains":
    Code:
    <VirtualHost *:80>
        ServerName dev.docsearch.net
        DocumentRoot "html/docsearch/public/"
    I haven't tried this online, but I presume that if you had dev.docsearch.net registered to your IP, it gets directed to your server which then decides what to use as DocumentRoot.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #6
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by maxorator View Post
    The server that is hosting CProgramming is configured to support multiple domain names, therefore it doesn't show CProgramming site when you enter the IP address.

    Are you wondering how the server knows which domain you are requesting even though the client resolves the domain name before sending the request? It's pretty simple actually - the domain name is included in the HTTP headers.
    This answers my question.
    I didn't know there was such a feature - but I guess it was stupid of me not to guess to the obvious.
    Thanks.

  7. #7
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    In fact google.com resolves to many different addresses. A records don't have to be a 1-to-1 mapping of hostname to IP.

  8. #8
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    I know. It seems that most resolvers just use the first one they see, I'd only be interested in the others if the first one failed to get me anywhere. (But I've not seen any browser do that, so in practicality, the other IPs are somewhat pointless.)

  9. #9
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Not really. Having multiple IPs is a poor man's way of load balancing. Basically you get round robin DNS.

  10. #10
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Does that mean that a 'nice' resolver should randomly choose from the list? If so, most are mean. Or will the DNS host shuffle them after a while? Or the target site's NS give a shuffled list to other nameserver?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting 32 bit binary IP to decimal IP (vice-versa)
    By Mankthetank19 in forum C Programming
    Replies: 15
    Last Post: 12-28-2009, 07:17 PM
  2. strstr problem
    By Kempelen in forum C Programming
    Replies: 2
    Last Post: 09-08-2009, 03:46 AM
  3. IP access and DNS access to Cprog.com
    By mithrandir in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 08-31-2002, 07:22 PM