Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

It is possible to use wildcard in /etc/hosts file?

For example, im developng the application that will have user-defined subdomains, like "", "".

Im looking for something like this: *

How can i make it work ?

share|improve this question

No. You need a full blown DNS server to do this.

share|improve this answer
Second that, you can't. – Kyle Brandt Aug 7 '09 at 19:47

No you can't as has been stated, but...

If the hostnames follow what you are saying though, you could do this with the Bash shell to save you some typing:

for i in user{1..10}; do 
    sudo bash -c "echo ${i} >> /etc/hosts"

Or, say you have them all in a text file one host per line:

while read host; do
    sudo bash -c "echo $host >> /etc/hosts"
done < fileName
share|improve this answer
of course, i can use static names, but the question not about it. thanks anyway. – Dan Sosedoff Aug 7 '09 at 20:43

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.