Solved

Wilcard DNS Zone/Apache Catchall

Posted on 2009-04-02
4
602 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 W 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 W
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I've written instructions for one router type, but this principle may be useful for others of the same brand and even other brands of router. Problem: I had an issue especially with mobile devices that refused to use DNS information supplied via…
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.
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.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now