63

Is it possible for many domain names to share one IP address? For example, www.xjtl.com, www.fmie.com, sdmfl.com, etc.

Hundreds of domain names share just one IP – when you do a DNS query for each of them, the same IP is returned.

Are there any laws or Internet rules that disallow this?

5
  • 16
    Why would there be laws against this? Apr 2, 2013 at 22:14
  • It is a little irritating, since spammers may create hundreds of different domains linked to one IP. But the technique has many legitimate uses. Apr 2, 2013 at 23:55
  • 9
    Disallowing it will increase web hosting costs and we will run out of IPV4 addresses immediately.
    – Yousf
    Apr 3, 2013 at 9:22
  • 2
    @AthomSfere - Indeed. I think it's interesting that he mentioned it, however, in that it reminds us what it was like to have, at one time, not know what we know now. To the initiated, it sounds absurd to think there might be laws against shared IP addresses. However, reflect on the assumptions you had to make about esoteric subjects before you understood them. New concepts in software are often a black, murky shape that take some time to figure out. In the meantime, the brain fills in some blanks by making up what sometimes amounts to gibberish. It's all part of the learning process.
    – bubbleking
    Feb 19, 2016 at 20:27
  • This is very useful. I have a lot of domain names linked to my public IP address. As @Yousf said I shouldn't have a lot of public IP address just for me. One is enough and I can provide a lot of websites for my company. Each domain name as it's own digital certificate. That's safe because each certificate is associated to specif name, not to IP. You just need to prove that the name is yours wen you submit the certificate request.
    – Maf
    Dec 9, 2022 at 1:01

7 Answers 7

90

Yes, this is an extremely common practice. It is called a Shared Web Hosting:

In name-based virtual hosting, also called shared IP hosting, the virtual hosts serve multiple hostnames on a single machine with a single IP address. This is possible because when a web browser requests a resource from a web server using HTTP/1.1 it includes the requested hostname as part of the request. The server uses this information to determine which web site to show the user. When you register/purchase your domain name on a particular "registrars name server", your DNS settings are kept on their server, and in most cases point your domain to the Name Server of your hosting provider. This Name Server is where the IP number (currently associated with your domain name) resides.

Any time you have a website that you look up its IP and when you type the IP directly into the browser and you got a different website, you just encountered Shared Hosting.


In fact, this website here uses it. Ping superuser.com or stackoverflow.com and you will get 198.252.206.16 for both. If you type that IP address into your browser, it will not work and you will get an error saying the site does not exist because it did not have a hostname to check and see which site it should serve you.

7
  • I thought shared web hosting has some naming restriction, like if the root domain name is prop.com, then those domain names should be named like a.prop.com, fld.prop.com, belt.prop.com, anyway, they must have suffix prop.com?
    – misteryes
    Apr 2, 2013 at 23:23
  • 2
    Setting up virtual hosting is pretty easy to do (at least on Apache.) httpd.apache.org/docs/2.2/vhosts/examples.html Apr 3, 2013 at 0:23
  • 2
    @misteryes No, there is no restriction. All that matters is the same program hosts the all of the sites so it can intercept the hostname as part of the HTTP/1.1 header then serve the correct web page. Apr 3, 2013 at 3:56
  • @misteryes What you are thinking of is called sub domains.
    – Hansi
    Apr 5, 2013 at 10:35
  • Is it posible to vist one of the other SE sites by typing the IP?
    – Qwertie
    Feb 13, 2014 at 23:20
23

Shared web hosting is also for the case of different people, each with one or many different domain names, in addition to the cases of one or more different sub-domains.

For example, I have about 30 domain names on a single web hosting account. The files for my "First" domain name are located in the root of my "public_html" folder. This folder is in my "home" directory, so something like: ".../.../username/home/public_html".

And, in the root of this folder are folders for each sub-domain of my "First" domain name. Lets say my "First" domain name is "example.com", and I have some sub-domains. The files will be organized like this:

"example.com"  -->  ".../username/home/public_html"
"a.example.com"  -->  ".../username/home/public_html/a"
"b.example.com"  -->  ".../username/home/public_html/b"
"c.example.com"  -->  ".../username/home/public_html/c"

Plus, there is another folder in public_html for each of my other additional domain names (referred to as "add-on" domains in my hosting).

"domain2.com"  -->  ".../username/home/public_html/somefolder"
"domain3.com"  -->  ".../username/home/public_html/otherfolder"
"a.domain2.com"  -->  ".../username/home/public_html/somefolder/a"
"b.domain3.com"  -->  ".../username/home/public_html/otherfolder/b"

Plus, many other people (perhaps dozens of people), each having a different "username", all have hosting accounts on the same computer, and each of these other users may have one or many domains and sub-domains, with their files organized in a similar fashion.

All of these users, including me, all share the same IP address. If I want, I could pay extra to have one or more unique IP addresses for my domains.

Originally, at least in concept, I believe the internet was setup with each domain name to have a different IP address. I think around the time of HTTP/1.1 this was changed to allow multiple domain names to share a single IP address. This was done then because of the concern of running out of IP addresses.

3
  • 2
    I wish I could give you some of my up-votes, you did a much better explanation than I did. Apr 3, 2013 at 4:39
  • OK, so this means that, if you have an additional domain called X, then you can't have a subdomain called X on your primary domain because it would be a name conflict. It will probably be a situation most people don't run into, but still worth mentioning. Dec 18, 2015 at 23:01
  • @RaduMurzea - In many cases, that is correct. But, this could depend on the web hosting account. With some web hosts, the "additional domain" (example.com), and the folder that it is pointing to, are configured separately. So, where you define/configure your additional domain like: example.com, you also create/specify a folder name for that domain like "/some-unrelated-folder-name". Dec 21, 2015 at 11:42
7

IPs are scarce. Not only are there no rules that disallow this but it is strongly encouraged. Use of IP addresses must be justified by some kind of need.

6

It is possible, and it often makes sense.

Say you owned the website and brand for Firefox, you would want to make sure all hits for Firefox and typed URLs that might be confused for your resolved to your IP, so you buy Firefox.com, Firefox.org, FF.com, FF.org, Firefix.org and Firefix.com. You not also buy 6 different IPs, you would point them all to the same IP. Lets say Firefox bought out Maxthon browser, you would then point all of Maxthon's domains to your IP too.

There is no reason for there to laws against it...

4

You can indeed host many many websites on the same IP address. Though, if you want your website to use secure HTTP (HTTPS), then you have to use a unique IP address for that web site only.

You need to use secure HTTP if your website visitors are able to log into your site or if some other sensitive information is transferred to their browser. So, something like an e-commerce site would need to have its own IP address that is not shared with anything else in order to encrypt credit card details and the like.

5
  • 2
    Not true, the Server Name Identification extension to SSL solves that problem. It is not 100% supported, but all modern browsers work with it. Apr 3, 2013 at 19:42
  • +1. this is an important extra detail for the OP's question. Scott Chamberlain's caveat is important also, but "all modern browsers work with it" is an overstatement, so the existence of SNI does not invalidate Jack Hughes' point.
    – mc0e
    Aug 21, 2014 at 16:12
  • 1
    Indeed, if you use SNI you are pretty much dumping your Windows XP user base. Aug 22, 2014 at 7:58
  • @JackHughes like Microsoft... May 29, 2019 at 10:15
  • Please, edit this answer. That's not trueI have a lot of domain names linked to my public IP address. I shouldn't have a lot of public IP address just for me. One is enough and I can provide a lot of websites for my company. Each domain name as it's own digital certificate. That's safe because each certificate is associated to specif name, not to IP. You just need to prove that the name is yours wen you submit the certificate request.
    – Maf
    Dec 9, 2022 at 1:03
1

simple way is to have each domain use different directories on your server. When you go to www.example.com it will forward you to 208.352.12.24/website and if you have www.example2.com you could forward it to 208.352.12.24/website2 etc.. idk hope this helps!

0

Suppose We have this Law like 'you can use only one domain name associated with one IP Address'. In that case, since we have limited number of IP Addresses, We will have limited number of Domain Names. So once we have consumed all IP addresses, there will not be any new player in Town.
And So business got stuck and there will be fight for domain names or so. No new domain, no new company and everything falls apart.
So there will be voices against such law and so either erase the law or modify it. And we prefer no such law. So simply there is no such law which limits business growth till its in right direction.

2
  • That's not entirely true. No new companies because they can't get a domain? What about all of the companies that don't necessarily need a web presence to do their job, such as a manufacturing company that could do fax/mail orders?
    – Kruug
    Apr 3, 2013 at 13:27
  • I meant companies, with internet presence
    – skyemporer
    Apr 4, 2013 at 9:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .