Solved

Wilcard DNS Zone/Apache Catchall

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

810 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