topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday December 12, 2024, 3:37 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: a little linux DNS/DHCP help requested  (Read 4923 times)

slickjer

  • Participant
  • Joined in 2007
  • *
  • default avatar
  • Posts: 3
    • View Profile
    • Donate to Member
a little linux DNS/DHCP help requested
« on: April 05, 2007, 04:32 PM »
Hello! I'm having a problem setting up my FC5 box (I'm in iraq, and my FC6 DVD got ruined. Go figure.) The problem is as follows:
I've created a sweet website with lots of information pertaining to all the people living near us, I have all the hardware set up, and I've got apache/php/mysql running great on my linux box. I have BIND installed, and I assume it's working correctly since it starts up fine. Here's what I'd like to do:
I need to get my *NIX server working as a DCHP/DNS server, and have all requests meant for ANY website to be redirected back to the *NIX box (127.0.0.1). I've been using the DHCP on one of our routers to assign IP's to clients so far, but that's just until I get it working on the *NIX box. For now the *NIX box is on a seperate switch connected to the WAN port of the main router. The router is doing DHCP fine, and it's set to use the *NIX box for DNS. All the clients can access the *NIX box just fine to pull up the site by entering the IP manually. I can figure out the DHCP stuff on my own, but I need help with the DNS.
So the real problem is, how do I configure the DNS server on the *NIX box to redirect traffic meant for any website back to itself? I'll use a 404 file to redirect back to the main page, but I can't figure out how to set up BIND correctly for the life of me. Those "zone files" and the named.conf are a little much for someone who's never played with DNS much, and not on a *NIX box at all.
Any help greatly appreciated!
 -- Jer

Gothi[c]

  • DC Server Admin
  • Charter Honorary Member
  • Joined in 2006
  • ***
  • Posts: 873
    • View Profile
    • linkerror
    • Donate to Member
Re: a little linux DNS/DHCP help requested
« Reply #1 on: April 05, 2007, 05:49 PM »
Configuring bind for me is usually allot of trial and error, It's an get-it-over-with-and-forget-about thing :)
I'd have to dive into man pages to answer that, but I suggest you ask on irc, in the #bind channel on the server irc.freenode.net

slickjer

  • Participant
  • Joined in 2007
  • *
  • default avatar
  • Posts: 3
    • View Profile
    • Donate to Member
Re: a little linux DNS/DHCP help requested
« Reply #2 on: April 05, 2007, 05:54 PM »
Thanks for the reply! I agree, so far BIND is just being a huge pain the ASCII. I'd love to come on IRC, but I'm using military computers on military internet in Iraq. They've got it all boarded up. I could probably get around it, but the consequences if caught would be dire. I downloaded all the man pages, I guess I'll try and learn BIND completely from scratch. Argh! Lol. Thanks again for the post!

Gothi[c]

  • DC Server Admin
  • Charter Honorary Member
  • Joined in 2006
  • ***
  • Posts: 873
    • View Profile
    • linkerror
    • Donate to Member
Re: a little linux DNS/DHCP help requested
« Reply #3 on: April 05, 2007, 06:28 PM »
19:01 < Gothi[c]> How do I configure bind so add dns requests
                  (eg bleh.com, meh.bleh.com,
                  foo.meh.bleh.com,...) point to the same
                  machine? can i add zones with wildchars?
19:14 < vchrizz> Gothi[c], i think you want CNAME records ..
                 http://www.zytrax.com/books/dns/ch8/cname.html

Hope that helps...

slickjer

  • Participant
  • Joined in 2007
  • *
  • default avatar
  • Posts: 3
    • View Profile
    • Donate to Member
Re: a little linux DNS/DHCP help requested
« Reply #4 on: April 06, 2007, 02:05 PM »
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. :P

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!