Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wildcard in DNS & Apache

Here is a nice idea for people that have like webhosting or just run any websites with subdomains. Also i often type a url like


So a wildcard will catch any not matched dns entry and point it to a IP. Say I have this simple dns zone file


                       NS               MX      5               MX      20               A
www                             CNAME


Now I add the following to the end of the zone file for the wildcard


*             IN      A


Now reload named.


service named reload


So that will take all random subdomains people may try and then send them to the IP of my webserver for example. We can easily test that


[root@web1 named]# host has address
[root@web1 named]# host has address
[root@web1 named]# host has address 666.111.22.33


So now that bind is all setup we need to do the same for apache. You need to have your virtualhosting setup in apache for this to work


So we add the following simple section at the bottom of the httpd.conf file


DocumentRoot /var/www/html
ServerAlias *


That is very simplified.. so you can always add more entries if needed like the logs or such. Now just restart apache


service httpd restart


Now you should be able to enter into your browser and it should take you to your website.


Forum Jump:

Users browsing this thread: 1 Guest(s)