Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a lot of subdomains in the main domain xxx.zzz

So, for this domain, I can have


Istead of adding each subdomain in the host file, I would like to add only the main domain xxx.zzz and then to be able to access all the subdomains.

I have tryed with *.xxx.zzz but apparently, this will not work (Linux or Windows).

Any idea is welcome. Thank you very much.

share|improve this question
In short: you should use a DNS. Setup and internal DNS server and add those subdomains. – eldblz Dec 18 '12 at 8:01
@eldblz, thank you. In fact, I am using a DNS on the server sidde but how to add only the main domain in the dns file, not all the subdomains? – Milos Dec 18 '12 at 8:08
up vote 4 down vote accepted

Wildcards don't work in hosts files. You either have to write them all:


or setup proper DNS

share|improve this answer
Thank's a tot for the answer. I am using a DNS and I have the same problem. – Milos Dec 18 '12 at 8:05

If you REALLY want this to work you should be using DNS as stated but if you're not in control of DNS and need to use the HOSTS file, you can use a DNS Proxy on your PC which allows wildcards in its own HOSTS file.

Example is in this thread, read down to the post about Acrilic DNS :

share|improve this answer
Thank you very much... – Milos Dec 18 '12 at 9:52

Wildcard syntax is possible in full-featured DNS servers. For BIND record should look like this: 3600 IN  A
*     3600 IN  CNAME

If you clarify what DNS server you use I can provide an example for it.

share|improve this answer
Thanks a lot... – Milos Dec 18 '12 at 9:52

Your Answer


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.