controlling DHCP

David Rosenstrauch darose at darose.net
Thu Apr 27 10:21:23 EDT 2006


Well, first off, it sounds like what you really want is to give the 
desktop machine a static IP address.  The "D" in DHCP stands for 
"dynamic", so technically what you're trying to do is a contradiction: 
you want a dynamic IP server to serve up static addresses.  Well, why 
not solve the problem by avoiding it, and just give the server a static 
IP?  This will allow you to do port forwarding to the server.  For the 
rest of the machines, you can just use plain old DHCP, since you don't 
care what address they get assigned.

That said, I have heard of routers that can assign specific IP's to 
machines with, say, a specific MAC address, which basically accomplishes 
what you want:  having a DHCP server serve up static IP's.  Still, I 
wouldn't recommend going this route 1) since it's not necessary, as 
you'll see below, and 2) since you've already seen that this is 
problematic if you use different MAC addresses (i.e, different network 
cards) on the same machine.

The other issue that I'm reading that you have here, and which I think 
is the piece that you're not grasping here, is that your internal 
network has no internal DNS server.  This means that there's no way for 
you to refer to another PC on your network by name, and so you're forced 
to use its IP address.  You've compensated for this by manually editing 
the hosts files on each machine, linking IP and name for all the other 
machines.  But this causes another problem:  that restricts you from 
using DHCP to assign the other machines their IP addresses.  Because if 
the machine gets assigned a different IP address, then all your hosts 
records are wrong.  This, it sounds like, is the other reason why you're 
following the route of trying to get your DHCP server to serve up fixed 
addresses.

Really, though, a better solution to the problem is this:  run an 
internal DNS server on your LAN, and your problem is solved.  Assign the 
server a static IP, let all the other machines get assigned a dynamic 
IP, and then the internal DNS server will let you refer to all the 
machines by name instead of IP.

I do this very thing on my local network and it works great.  It 
probably sounds complicated - and it would be if you were running a 
complicated DNS server like BIND.  But if you use a DNS server that's 
simpler and targeted to small LAN's like yours, then it's really pretty 
easy.  Fortunately, such an animal exists:  dnsmasq. 
(http://thekelleys.org.uk/dnsmasq/doc.html)  Dnsmasq is a pretty simple 
and easy to use combination DHCP and DNS server for small LAN's.

I'm not going to go into the details of configuring it (you can email me 
off-list if you're interested), but basically what you'd do is this:

* turn off DHCP in your router
* install dnsmasq in your server
* configure dnsmasq for serving up both DHCP and DNS
* tweak 1 or 2 other network/dns settings on your server
* feel joy

Check it out!  I started using dnsmasq a couple of years ago.  It's been 
"set it and forget it" and I've been happy ever since.

HTH.  Feel free to email back if you have more questions.

DR

Laura Conrad wrote:
> I have a router with a dhcp server on my home network.  When I set it
> up, I told it to allow the ip address leases to last forever, thinking
> that would mean that my desktop computer would always be 192.168.2.2,
> and my laptop and printer would also have fixed addresses.  Then I let
> some ports through the firewall for apache and mail and such,
> specifying the desktop IP address as what to forward them to.  I also
> have hosts files on the computers, which let me refer to the other
> machines by name instead of number.
> 
> Unfortunately, these leases seem to last only until the next power
> outage, which has been a fairly short time in this neighborhood
> lately.  To compound the confusion, this morning when the router came
> up, it gave the former desktop IP to the printer, so when a friend
> tried to check some files we were working on, he got the printer
> configuration.
> 
> Does anyone know how to tell a dhcp server to use specific addresses?
> I'd ideally like something like:
> 
>     Desktop machine (debian)            192.168.2.2
>     Laptop running windows              192.168.2.3
>     Laptop running linux (ubuntu)       192.168.2.4
>     Printer                             192.168.2.5
> 
> At the moment, even when it can remember the addresses it had before,
> it gives them out by Mac address, so the laptop is one address when
> it's hooked up to an ethernet cable and a different one when it's
> running wireless, regardless of operating system.
> 
> 




More information about the Discuss mailing list