Solved

Wilcard DNS Zone/Apache Catchall

Posted on 2009-04-02
4
616 Views
Last Modified: 2013-11-30
I don't change dns entries often, so I'm not too familiar with bind. My server is running bind 9.3.4 and Apache 2.2.3. My name servers and httpd server are on the same box:

ns1.domain.com
ns2.domain.com
www.domain.com

I know how to setup a wildcard subdomain so that *.domain.com redirects to the server root I want it to. What I want to do though is make it so that any domains pointed to my name servers resolve and redirect to the webserver. I'm not sure if I need to set this up in my /etc/named.conf , or in my httpd.conf

Thank you
0
Comment
Question by:DCQC
  • 2
  • 2
4 Comments
 
LVL 29

Accepted Solution

by:
Michael Worsham earned 500 total points
ID: 24060052
If someone points a domain's zone record at your name server(s) and you don't have a DNS zone file available for it, the site isn't going to be going anywhere as the DNS server will not propagate it to the rest of the world that it is authoritative for the domain. Your site will have to be seen as authoritative for the domain, thus will require a 3rd level or top level DNS zone file for each and every domain that uses your DNS server as its query site.

Now, if the domain in question did have a zone file on your DNS server and you were authorative for the domain, but doesn't have a main A record in place, then you could use a wildcard catchall and point the site to a Apache catchall on your web server.


$TTL 86400
@       IN      SOA     ns1.domain.com. postmaster.domain.com. ( 
                                        2009032302 ;Serial
                                        10800   ; Refresh every hour
                                        3600    ; Retry every hour
                                        604800  ; Expire after a week
                                        86400 ) ; Minimum ttl of 1 day
        IN      NS              ns1.domain.com.
        IN      NS              ns2.domain.com.
        IN      MX      10      mail.domain.com.
 
;mydomain.com hosts
www             CNAME           mydomain.com.
 
;;;;;;;;;;;;;;;;;;;;;;;Wildcard Catchall;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;DO NOT PUT ANY RECORD ENTRIES BELOW THIS;;;;;;;;;;;;;;;;
*       IN      A              111.222.333.444 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 
 
NameVirtualHost *
Listen 111.222.333.444:80
#############################
<VirtualHost *>
   ServerName mydomain.com
   ServerAlias *.mydomain.com
   DocumentRoot /web/mydomain.com/htdocs
   ErrorLog /var/web/mydomain.com/error_log
   CustomLog /var/web/mydomain.com/access_log common
   ScriptAlias /cgi-bin/ "/web/mydomain.com/htdocs/"
   <Directory /web/mydomain.com>
      Options Indexes FollowSymLinks Multiviews +Includes
      AllowOverride All
   </Directory>
</VirtualHost>

Open in new window

0
 

Author Comment

by:DCQC
ID: 24060599
So there's no way to create a *.com, *.net, etc zone file? Basically I'm going to have multiple domains all pointed to the same webserver, all loading the same content. There will be new domains added all the time, and sooner or later domains being removed from the list as well. Was just trying to save a hassle in the upkeep of them.

Would the answer be to create a template of your two snippets there mwecomputers? And then a script to create the proper entries each time they were needed?

0
 
LVL 29

Expert Comment

by:Michael Worsham
ID: 24061120
Under standard DNS zones, you cannot have a db.*.com site or any derivative of the other suffixes.
Each domain will need its own DNS zone stub file (like I have listed in the snippet above).

One recommended option would be to setup a redirect hosting entry...

DNS for mydomain.com, add in the following:

redirect IN A <ip address of apache webserver> (see below for what I am talking about)


And in each DNS stub file, add in this:

;;;;;;;;;;;;;;;;;;;;;;;Wildcard Catchall;;;;;;;;;;;;;;;;;;;;;;;;;
*       IN      CNAME                  redirect.mydomain.com
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


---

Then in the Apache httpd.conf (or for ease of adding more sites, create a virtualhost.conf and include it in the main httpd.conf [Include /etc/httpd/conf/virthosts.conf])

Listen 111.222.333.444:80
NameVirtualHost *

<VirtualHost redirect.mydomain.com>
   ServerName domain.com
   ServerAlias www.domain1.com
   ServerAlias *.domain1.com
   ServerAlias domain2.com
   ServerAlias www.domain2.com
   ServerAlias *.domain2.com
   Redirect / http://mydomain.com  #This is where you want all the sites to end up at
   AccessLog /dev/null common
   ErrorLog /dev/null
</VirtualHost>
0
 

Author Closing Comment

by:DCQC
ID: 31566105
Using these snippets in a script to automate domain zone generation did the trick. Thank you
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PRTG Network Monitor lets you monitor your bandwidth usage, so you know who is using up your bandwidth, and what they're using it for.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question