Can the same dedicated IP address be used for parent and sub domains?

I’ve had this problem before but never bothered taking it further but I’m now wanting to know if this is possible or I’m missing something.
If I have a domain and give it a dedicated IP address and then create a sub-domain, can the sub-domain and the parent domain have the same address? If so, what’s the process to get that working?
Thanks in advance.


Is there a particular reason you are assigning a dedicate IP to the domain in the first place? In “most” cases, you should be conforming with best practises regarding IP addresses, which is to setup “name-based” hosting instead of “ip-based” hosting in order to conserve the IP space, hence my initial curiosity.

Yes, you should just be able to specify it in the “Network Interface” field in the “IP Address and Forwarding” section. Set it to “Virtual with IP”, and choose “Already active” if the address is already up on the system (as it will be after you created the top-level server on that IP.

Virtualmin doesn’t care, as far as I know, how you divide up your IPs. It used to matter when SSL require another IP, and so you couldn’t readily share an IP address if it had an SSL site on it, but it’s been years since that was a thing.

Thanks and yes that’s what I thought too but I’m getting a “Failed to create virtual server : The IP address is already used by virtual server” error and the IP address is only being used for the parent domain. Am I missing a setting somewhere?

We’re building sites for customers who host elsewhere at present. They want their own IP addresses and it’s easier to work on CMSs via IP address if the name is pointing elsewhere.

Huh. Well, that’s interesting. And, it shouldn’t happen. It might be a holdover from back when there needed to be dedicated IP addresses for SSL; it may just mean we need to loosen that validation check (or there may be some issues I’m not thinking of, I’ll have to ask Jamie when he’s awake tomorrow).

Obviously, this doesn’t come up much, since there’s almost no reason not to share IPs. But, I really feel like it’s possible somehow to share an IP for a user. It may be a Pro-only feature, now that I’m thinking of it in those terms. A lot of reseller hosting type features are only in Pro (since the folks who need it are the folks making money with Virtualmin and we want a little to come our way). If Jamie doesn’t know offhand, I’ll poke around and figure out what’s going on with that and see how difficult it’d be to make it work.


If I understand you correctly, you could technically setup “name-based” hosting for the domain, then to work on the site while it’s hosted elsewhere, just setup a rule in your computer’s “hosts” file, which points the domain to your server.

This will effectively trick your computer into thinking the DNS has already been changed, allow you to work on and test the site as if it were already hosted completely by you, then after moving the DNS formerly, simply delete the entry in the “hosts” file on your computer.

I test new sites this way all the time, and it allows me to debug and confirm the site is fully operational before the general public can see the changes.

Just a thought :slight_smile: