Search code examples
network-programmingdnsip-addressnslookup

IP address from nslookup sometimes doesn't work, e.g. with wikipedia


As I understand it, nslookup [domain_name] will give you the IP address of a domain name. When I run nslookup wikipedia.org, I get

    Server:     138.23.146.213
    Address:    138.23.146.213#53

    Non-authoritative answer:
    Name:   wikipedia.org
    Address: 198.35.26.96

So if I enter 198.35.26.96 in my web browser, I should reach wikipedia.org. This works for some websites, like google.com and facebook.com, and mozilla.org. But it gets an error for other websites, like wikipedia.org, craiglist.org, and wordpress.org.

Does anybody know why?


Solution

  • An IP address identifies a server, not a website. There might be more than one websites hosted on the same server.

    When you enter a domain name (eg. wikipedia.org) in your browser's address bar, your browser first resolves the domain name to get an IP address (that is 198.35.26.96). Then it constructs an HTTP request having a parameter named Host with a value wikipedia.org and sends it to the address 198.35.26.96.

    The server receives the response, reads the Host parameter and knows which website the user is looking for. So the browser essentially needs both IP address of the server and domain name of the website to open it.

    In some web servers a "default website" might be defined, that is if the Host parameter is absent or its value is an IP address then the server will serve the default website to the user. This was the case with google.com and facebook.com. If a default website has not been set (eg. in wikipedia.org), the server will simply reply with an error saying the domain was not found.