PDA

View Full Version : DNS for LANs with DHCP



MerePeer
06-16-2004, 04:28 PM
I was blissfully unaware of the Microsoft (M$) netbios-over-tcp-dns-name-resolution activity (i.e. "nbtstat -c" at the cmd line). Now that I have Linux on the LAN I need a DNS solution for both Winboxen to find Linboxen and vice versa. I'm wondering what other folks might have done to solve this?

I want to avoid static I/Ps (exception for 1 box if it needs to be DNS and/or DHCP server), and don't want to maintain hosts files on all boxen. I currently have a Linksys router as my DHCP, and that's nice because both Win and Lin boxen receive the ISP's DNS I/P addresses from it (however ISP doesn't seem to chg these more than -- say -- once a year).

I was starting to read the O'Reilly BIND book, and it seems a shame to have to read an entire manual just to get some simple name/IPs resolved on a LAN. My thinking is I need to dedicate one Lin box as both a DHCP and DNS server and use BIND 9 which (I thought I saw somewhere) supports dynamic DNS update records?

And once it is all working -- I wonder which Windows services can be shutoff? Surely "TCP/IP NetBIOS Helper". That'll probably buy me a couple work units on some project!! :)

QIbHom
06-16-2004, 05:22 PM
Can you use your router to serve DHCP? Some Linksys routers do that, I think.

Alternately, write up a hosts file on each computer, pointing to the network computers by IP and name.

I have all Linux computers, but the issue still exists. What I do is have my router interact with my ISP (enable NAT), it assigns IP addresses to my LAN (so they are essentially static, internally), and I just put a hosts file on each computer with pointers to my other computers.

MerePeer
06-16-2004, 05:39 PM
The problem with hosts files on each computer is that they have to be maintained -- so when DHCP hands out a different IP # (like after a power failure depending on reboot order) all hosts files will be out of date. If you are using static IP #s on your local boxen then this problem wont occur, but it is still an issue when you are adding boxen. I'd like to assume there is a solution for DHCP-based DNS names out there....and fallback to a static solution only if I can't find one.

IronBits
06-16-2004, 07:45 PM
I wrote a batch file/script to take care of maintaining HOSTS files on lots of computers.

@echo off
Notepad \windows\system32\drivers\etc\HOSTS
copy /Y \windows\system32\drivers\etc\HOSTS \\computername1\c$\windows\system32\drivers\etc
copy /Y \windows\system32\drivers\etc\HOSTS \\computername2\c$\windows\system32\drivers\etc
copy /Y \windows\system32\drivers\etc\HOSTS \\computername3\c$\windows\system32\drivers\etc

EXIT

:D

gopher_yarrowzoo
06-17-2004, 03:03 PM
okay this may seem silly - but I've got a Linux Box on ma network - fire it up - sees the whole network - no host file - none of my pc's have beyond the basic host file .

1 Machine is running Kerio WinRoute Pro 4.3 ;) - with DHCP enabled, DNS Forwarding on (DNS servers set by ISP) and NAT on the modem port..
Settings are Gateway, DNS, WINS all that machine i.e 192.168.1.1, Mask 255.255.255.0
Domain Name: DS 9 (cos I wanted it that way) - each machine has it's own name so they can all see each other
lease time: 4days
this is a Scope set up in WinRoute Pro 4.3

Hope that helps ya some MeerPeer

MerePeer
09-23-2004, 08:01 AM
Here's how I got this working:

1) I installed bind9, a DNS server. Normal setup as I recall, but I had to make up a domain.org and there are 3+ config files involved.

My router was a DHCP server, which meant it also was handing out the DNS IP list from my provider and NOT handing out my new local DNS IP #. So even if my local DNS had all the LAN computer names in it, they would be unused.

2) After writing down list of provider DNS IP #s, I shut off DHCP capability in the router.

3) Installed dhcp3, a DHCP server. Important dhcpd.conf lines, where "ddns" stands for "dynamic dns" and means that whenever DHCP offers up a new IP it will also tell the (local lan) DNS server about the IP and name:
ddns-update-style interim;
ddns-updates on;

Also inside dhcpd.conf (on the one dhcp server system) is where you put the DNS IP list saved from above:
option domain-name-servers 1.1.1.1, 2.2.2.2, 3.3.3.3;

4) Setting up one computer as the DHCP server means it must have a fixed IP # (i.e. cant DHCP request to itself). So that meant changing /etc/network/interfaces line "iface eht0 inet dhcp" into
iface eth0 inet static
and adding the address, netmask, gateway etc (man interfaces).

5) At this point the Microsoft systems are very happy, but the Linux systems still cant ping each other (but can ping Microsoft). This was solved by making sure that the dhclient.conf file on each system was telling the dhcp server its name when it requested a dhcp IP #:
send host-name "blah"; #replace blah with that computer's name
Note: on redhat dist this file is dhclient-eth0.conf and I think already had this in place.

6) Now linux can ping other linux if they use the whole domain name, i.e. ping hostname.domain.org, but I recall issues just pinging by hostname alone. I know I needed "search domain.org" to be in each linux /etc/resolv.conf, BUT lines in that file are generated automatically when they make their dhcp request. I think(?) the solution was to add this line back on the dhcp server box in the dhcpd.conf file:
option domain-name "domain.org"; # replace domain.org with yours

That doesnt help the DNS server itself because it isnt uing dhcp to gets its IP # (fixed), so only on the DNS server I added
search domain.org
to /etc/resolvconf/resolv.conf.d/tail

I think thats it -- it was a while ago and I should have posted while it was fresh.

Besides solving my initial issue of accessing (linux to linux) computers by name on the LAN, having a local DNS caches all the domain names/IPs so that the second time they are used by any computer on the LAN it doesnt go out to my provider's DNS to get resolved (until they expire (configurable)). Every bit counts...
:)