views:

273

answers:

1

I have a setup where one webserver (bar.com) is serving lots of subdomains, so it would be convenient to use a wildcard DNS entry. At the same time I'd like to use bar.com as search domain, so that foo resolves to foo.bar.com.

The problem now is that if I set it up like this, foo.com resolves to the webservers IP if there is no foo.com elsewhere (i.e. it first tries foo.com, fails, and then tries foo.com.bar.com, which gets matched by the wildcard).

This is very inconvenient because any hostname typos ends up at the webserver instead of producing an error. Is there a way to resolve this without specifying all the subdomains explicitly? I'm thinking something like a rule saying only "bare" hostnames (i.e. names without a dot in it) should go to the webserver. (I'm using BIND as DNS server, but the answer is probably general).

A: 

You are saying that:

  1. if someone requests an A record for a not existing subdomain you want it to return a specified address
  2. if someone requests an A record for a not existing subdomain you don't want it to return an address

Choose one of the two... I would say, automate the updating of your zone files.

According to (my interpretation of) RFC 1034, what you want is not possible.

An extremely ugly hack you could try, is adding bogus records for com (and every single other toplevel domain in the world)...

So:

  *.example.com IN A 1.2.3.4
com.example.com IN A 0.0.0.0

or even uglier:

  *.example.com IN A 1.2.3.4
com.example.com IN CNAME com.

I wish I never had thought of such horrible ideas, please forget immediately I ever mentioned this :)

Tader
Yes, I know what is causing the problem, but I was thinking something like a rule saying "only match stuff without subdomains". If it was a regexp [^\.]+.bar.com =)
Joakim Lundborg