DHCP and DNS for a Private Network
If you have more than a couple of machines and do have at least 1 permanently-connected server, I think you'll find life easier if you use both DHCP and DNS provided from that server.
Here's what I would do:
==== Pick an internal domain name. ==== If you have an existing domain name like example.com then you could use a subdomain of it such as 'int.example.com' for internal hosts, or if you don't have one then you can make up an 'impossible' top-level domain such as localnet. I shall use the TLD 'localnet' as an example.
Pick an address range to use for your network.
If you have an address range assigned by your ISP then use that, otherwise pick one of the RFC1918 ranges. I'll choose 192.168.1.0/24 (192.168.1.0 -> 192.168.1.255 inclusive) as an example.
Partition off part of your range for static hosts and the other half for DHCP hosts.
In this example I'll decide to put permanently connected machines and IPs I pin by MAC address into 192.168.1.0 -> 127. .0 and .255 will be unsuable as network and broadcast so my first host will be on .1.
Set it to hand out addresses in the range 192.168.1.128 -> .254. Test this. Any laptops and such that will be making a regular appearance on yuor network you may wish to pin their IP by the MAC address of their wireless card and put them in the first half of the range instead.
For machines that have wireless cards swapped in and out regulary there is no elegant solution other than hard-coding their IP address and not using DHCP for them.
Make it authoritative for two zones: localnet and 1.168.192.in-addr.arpa.
The main content of the localnet zone would be something like this:
router A 192.168.1.1 someserver A 192.168.1.2 adesktop A 192.168.1.3 laptop A 192.168.1.4
; generic DNS for dynamic IPs; you'd think the bind $GENERATE ; syntax would work here but it doesn't appear to support A ; records. 127.dyn A 192.168.1.127 128.dyn A 192.168.1.128 ; and so on up to 254.dyn..
The main content of the 1.168.192.in-addr.arpa zone would be something like this:
1 PTR router.localnet. 2 PTR someserver.localnet. 3 PTR adesktop.localnet. 4 PTR laptop.localnet.
; generic RDNS for dynamic IPs; $GENERATE works here. $GENERATE 127-254 $ PTR $.dyn.localnet.
0 When I get round to it, I will add something about using BIND9 & DHCPD3 to get proper dynamic dns working (no prexisting A or PTR records. Plug in a client - bam, both there). ChrisAitken
Make sure that all your machines have their resolv.conf set to use the bind machine as their resolver, and you can make it search the localnet domain for unqualified hosts first. their hostnames should either be unqualified or inside localnet domain. dhcpd can be configured do this for dynamic hosts.
If you do all that then you'll be able to refer to hosts by their short name ("someserver") or their full name ("someserver.localnet"). DNS lookups will work forwards and backwards. You will be able to plug laptops in and get a dynamic IP with generic forward and reverse dns like 127.dyn.localnet, or give them custom DNS by pinning their IP by MAC address.
When adding a new machine all you need to do is set its IP and hostname on itself and then set its name and reverse DNS in your two bind zones.