Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

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.

share|improve this answer
    
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. 127.0.0.1/file.zip instead of 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 <name> or nslookup <name> (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 127.8.9.10, then it is not possible. Great answer by the way, Tony. +1 –  Hyppy Aug 14 '11 at 16:43
show 2 more comments

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.

share|improve this answer
    
This is exactly what happened when I visited the IP address I got. –  Mark Aug 14 '11 at 16:44
add comment
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

share|improve this answer
    
dig didn't work. It gave me the same result as ping. I don't think I do have telnet access to my account, but I'll check that out. Thanks. –  Mark Aug 14 '11 at 16:38
    
erm i think you want to use ssh not telnet ;) –  anthonysomerset Aug 14 '11 at 19:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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