OK! I did some digging and some experimenting, and I found out that bind isn't nearly as big a pain as I previously thought. I'm going to be honest and tell you straight up front that I STILL don't know all that much, so don't expect anything stellar, but this method works fine.
Notes: You may be able to use wildcards, I haven't because I don't really think I need to. The way I did it is I just picked the 3 biggest sites I know people to go to (I checked the logs on my routers at work, and it confirmed what common sense told me.) They are: google, yahoo, and msn. (duh)
This works for me, but it may not work for you. Trial and error is key, and remember the little .'s at the end of fully qualified hostnames. Not sure what that means, but whatever. I figured out where the dots go my first try (after everything ending in .com
)
I'm assuming you have a working copy of BIND already, and that the named service starts up correctly for you.
OK!
First, we need to set up a zone for each of the sites we want to assign an IP address to. The zone, as far as I can tell, is just a nice way to set up seperate settings and files for different sites.
As root, open up /etc/named.conf (I used vi from shell, you can use whatever you like) and add the following for each site:
zone "sitename.com" {
type master;
file "sitename.com.zone";
};
This just states that we have a zone called "sitename.com", we're the master DNS server for it, and we're locating the site's information in the file "sitename.com.zone".
Next, we need to make sitename.com.zone in /var/named/chroot/var/named . The way I did it, since I don't know how long I really need the TTL to be and such, is I just did:
cp /var/named/chroot/var/named/localdomain.zone /var/named/chroot/var/named/sitename.com.zone
Now we have a copy of localdomain.zone as sitename.com.zone. Open that file up, and in the two places where you see "localdomain", change it to say "sitename.com.", making sure to add the . at the end both times. After you change the 2 places that say "localdomain" or "localhost" to "sitename.com." You should have a A record with 127.0.0.1 as the IP address. Change that IP to whatever IP you'd like that dns record to point to, and put the name of the server as something. I used "server1". After that, below the A listing, you can add a cname record pointing back to the A record. I should look something like this: (leaving out the NS line, because I can't remember it exactly off the top of my head.)
server1 IN A xxx.xxx.xxx.xxx
www IN CNAME server1
Add any other supdomains you'd like pointed there following the same format as the www line, or create a new A record with a different IP if you like, following the same format. Sorry about the spacing, I can't use "tab" to line it up all pretty on here.
Once that's finished, save the file, and then create a link to the file you just saved as /var/named/sitename.com.zone .
You'll need to restart named for the changes to take effect, either do "service named restart" if you're logged in as root locally, or "/sbin/service named restart" if you're using a remote shell. Try it out from another machine to make sure it works!
Hope this helps, I'll get an exact copy of the files I made next time I'm at a machine on the network, and update this post. Thanks for the help Gothic!