2

How should I set up a server to map all subdomains of a domain to an IP?

I wish I could do something like that in the hosts file:

127.0.0.1 *.example.com
Emanuil Rusev
  • 901
  • 3
  • 10
  • 16

1 Answers1

7

As mailq mentioned, DNS supports wildcard host entries (while the hosts file does not).

A DNS record with the name * will match all names for which there is no other record on that name, returning the wildcard record.

An entry would look like this:

*    IN    A    192.0.2.1

But, I'm not sure why you'd want to do that pointing to 127.0.0.1 - can you clarify what you're attempting to accomplish with this, and we might be able to point you in a better direction?

Shane Madden
  • 114,520
  • 13
  • 181
  • 251