Solved

Wilcard DNS Zone/Apache Catchall

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
P2P and MPLS 3 47
network error 8 36
Network access 4 24
Incredibly slow speeds while testing on server in China? 5 48
#Citrix #Citrix Netscaler #HTTP Compression #Load Balance
Don’t let your business fall victim to the coming apocalypse – use our Survival Guide for the Fax Apocalypse to identify the risks and signs of zombie fax activities at your business.
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

863 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

25 Experts available now in Live!

Get 1:1 Help Now