Solved

Wilcard DNS Zone/Apache Catchall

Posted on 2009-04-02
4
622 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

When it comes to security, there are always trade-offs between security and convenience/ease of administration. This article examines some of the main pros and cons of using key authentication vs password authentication for hosting an SFTP server.
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Suggested Courses

726 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