How-To: Wildcarded DNS

hackerpitbull

Verified User
Joined
Dec 25, 2004
Messages
92
These How-To been tested under FC2 & DA but should work for all Operating Systems with the required tools.

Required
- Apache (private httpd.conf for evrey domain [VirtualHost])
- DA
- Bind DNS (named)
- nano/pico editor

First lets edit domain conf':
Code:
nano /var/named/[i]domain.com[/i].db
Under
Code:
www     14400   IN      A       [i]ServerIP[/i]
ADD
Code:
*       14400   IN      A       [i]ServerIP[/i]
Under
Code:
root.[i]domain.com[/i]. (
You have the SN of the domain increase the last number by one.

Save & exit
ctrl+x then y then [ENTER]

Run:
/sbin/service named restart

Now lets edit httpd.conf of that domain (VirtualHost):
Code:
nano /usr/local/directadmin/data/users/[i]User-Name-Of-The-Domain[/i]/httpd.conf

In:
<VirtualHost ServerIP:80>
Under:
Code:
        ServerName [url]www.[/url][i]domain.com[/i]
ADD
Code:
        ServerAlias [url]www.*.[/url][i]domain.com[/i] *.[i]domain.com[/i]
        ServerAlias *.[i]domain.com[/i]

Save & exit
ctrl+x y [ENTER]

Run:
/sbin/service httpd restart

done :)
 
If you'd answered a specific thread with this exhautive and well thought-out reply, I'd let it go without comment.

But since you've posted it as a general How-To, I thought I'd mention this important point:

The "*" wildcard character, when used in a DNS zone, only matches when there is no other record in the zone.

For example if you have:

joe 14400 IN MX 10 example.com

then the "*" will NOT match joe for an A record.

And you're overusing restart, which depending on the number of zones, can actually take a while to restart DNS, leaving your DNS completely dead for a minute or more.

I'd suggest instead "service named reload". With some later versions of bind you can probably use "service named reload example.com", though i haven't tested it, so I don't know if service will pass the argument "example.com".

Jeff

Jeff
 
Back
Top