2

I have a virtual server (shared hosting), with a domain name (and several sub-accounts, each one a separate site also with its own domain name)

I was wondering if there was a way to find out the IP address of a domain name. I tried to ping it, but no dice. It just gives me the IP address of the physical server which is hosting my virtual one, or at least that's what I am assuming since it gives me the same IP for every domain name I have.

Sorry, while I'm not a technology newbie, I'm not familiar with this server stuff.

user9517
  • 114,104
  • 20
  • 206
  • 289
Mark
  • 23
  • 1
  • 1
  • 3

3 Answers3

6

Virtual Server and Shared Hosting tend to be different things although it doesn't affect my answer.

A single server (physical or virtual, it doesn't matter) can host websites for many different domains.

Each domain name will resolve to the same IP address, that of the server in question.

So www.example.com resolves to 198.51.100.21, but so does www.example.org. They're both hosted on the same server.

So when you ping www.example.com and www.example.org you get the same response, that's exactly how it should be if they are hosted by the same server.

Note: even if two domains resolve to different IP addresses, they could potentially be hosted on the same server, because a single server can support multiple IP addresses.

You can look up the IP address of server names / fully qualified domain names / web sites using tools like dig or nslookup. For example,

nslookup www.google.com

Non-authoritative answer:
www.google.com  canonical name = www.l.google.com.
Name:   www.l.google.com
Address: 74.125.113.103
Name:   www.l.google.com
Address: 74.125.113.104
Name:   www.l.google.com
Address: 74.125.113.105
Name:   www.l.google.com
Address: 74.125.113.106
Name:   www.l.google.com
Address: 74.125.113.147
Name:   www.l.google.com
Address: 74.125.113.99

When web servers host multiple sites (or domains), then the server needs to know which domain you're trying to get to (the name), and the IP address is not enough. This is why,

http://198.51.100.21/something

isn't usually possible with servers that have multiple domains hosted (especially true of web hosting providers).

There are many other reasons why using the IP address is undesirable as well.

I like to think of this like postal addresses. It's not sufficient to know someone's postal address (like a server IP address), you have to know their name as well (like the website domain) and write that on the letter. If you don't, you just know their mom (i.e. the default web site) is going to open it and read it.

EightBitTony
  • 9,211
  • 1
  • 32
  • 46
  • So, is there a way to find out the IP address of a specific domain name? For example, I have www.domain1.com and www.domain2.com hosted on the same server. I uploaded a file on www.domain1.com, and I want to give out a link in IP form, ie. http://127.0.0.1/file.zip instead of http://www.domain1.com/file.zip. Any way to do that? Thanks. – Mark Aug 14 '11 at 16:32
  • It depends what you mean by domain name. If you mean 'myserver.example.com' then yes, if you mean 'www.example.com' then yes, if you mean 'example.com' then maybe. You use dig or nslookup (or ping can work but it's only doing the lookup as a by-product of needing the ip address). – EightBitTony Aug 14 '11 at 16:34
  • Okay, you can look up the IP address, but what you're suggesting won't work because of how web servers handle multiple sites on the same server. Answer updated. – EightBitTony Aug 14 '11 at 16:35
  • I understand. So the bottom line is...I can't. Right? :) – Mark Aug 14 '11 at 16:40
  • Correct. Unless you control the "default" site, which is what you get browsing to an IP address like http://127.8.9.10/, then it is not possible. Great answer by the way, Tony. +1 – Hyppy Aug 14 '11 at 16:43
  • Thanks for your answer, Tony. Unfortunately I can't vote anyone up because I don't have enough reputation, but I appreciated it. – Mark Aug 14 '11 at 16:50
  • Mark - just wait until there's an answer you feel is most helpful, and then mark it as accepted (click the tick under it). – EightBitTony Aug 14 '11 at 17:00
3

It appears that on the server that hosts your domains, all of the hosted domains share the same IP address and this is the public IP address of the server. To direct traffic to the correct files for a particular domain, the host is using namebased virtual hosting. If you attempt to access any of the domains using an IP address you will most likely just get a default page from the host.

user9517
  • 114,104
  • 20
  • 206
  • 289
2
dig domain.com

will give you the ip your domain is pointed to (or nslookup if your on windows)

are you sure the "physical host" that you are hosting on is not your vps IP anyway? sounds like your provider might be doing some dodgy NAT if your website is pointed at an IP on the physical host and its not on your virtual machine

easiest way to find out is to login to your vps via ssh and run

ifconfig

this will tell you the IP of your server

anthonysomerset
  • 3,983
  • 2
  • 20
  • 24