LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   DHCP server auto-detect. (https://www.linuxquestions.org/questions/linux-networking-3/dhcp-server-auto-detect-799366/)

Raffles666 04-01-2010 08:27 AM

DHCP server auto-detect.
 
Hi,

I have a scenario where a Debian (in this case) device will be connected to an existing LAN.

What I then want said box to do, is to query the LAN to see if there is an existing DHCP server present. If there isn't one - then simply use the Debian box as the DHCP server (which works fine atm).

If there is an existing one - I need the Debian box to be able to turn off it's own internal one and get it's details from the existing server (ie. change from server to client).

These action will need to be sat in the background as well - just in case another DHCP server appears on the LAN after this box does. Don't shoot me for saying it - but I know Windoze server does this. Is there a 'script/util' that anyone knows of (I am trying to do this auto-magically)?

cheers

PS - Debian Etch if that makes a difference.

never say never 04-01-2010 10:26 AM

Probably a bad idea
 
Well it would be easy enough to write a script called by cron to monitor the network using a tool like dhcp_probe or RougeDetect, and that script could of course start and stop your dhcp server.

The problem is that the new dhcp server will not know about current leases.

For example, you plug in your box, it finds no DHCP Server and so it starts up dhcpd and starts serving up IP addresses. What if there are currently leased IPs on the network, your DHCP server will not be aware of them and could re-allocate them, causing duplicate IPs on the network.

The same is true if another device comes on-line after yours and starts serving DHCP, your DHCP server could have allocated say 192.168.0.101. Another DHCP Server starts up, which shuts your DHCP server down, and then a new request comes in it serves 192.168.0.101, now you have two computers with the same IP address on the same network. NOT GOOD!

If you are trying to provide redundancy you will need a DHCP server that can share information about DHCP allocations use DHCPD as part of a cluster, OR you will need to set up non overlapping IP Ranges (probably within the same subnet) to keep things going. This too of course will have some potential issues such as making sure the Gateway address, Subnet . . . are correct on both servers, and it will cause lease renewals to fail and a subsequent change in IP on a client device.

You may want to take a look at clustering your DHCP Server, so if one server goes down it will fail over to the remaining node(s) in the cluster, maintaining current lease info . . .

If I have missed the reason for wanting to do this, perhaps a more detailed explanation of what you want to accomplish and the reasoning behind it would be useful. I know Windows server with AD can do this as can Novell servers through e-directory, but just plain linux dhcpd doesn't leave the needed bread crumbs to make it seamless.

Hope this is helpful.

Raffles666 04-02-2010 08:14 AM

Thanks for the in-depth reply :)

The main reason for the question was the 'debian box [with dhcpd running] on to an existing LAN with an existing DHCP server' scenario.

I think I must have over-complicated the original question ;). My fault.

The idea is that if I have dhcpd running - it turns itself off if it finds an existing dhcp server somewhere on the same subnet.

The rest was just fluff.

I'll have a look at DHCP_PROBE now.

cheers


All times are GMT -5. The time now is 04:56 PM.