[Dnsmasq-discuss] Details of the --dhcp-optsdir=<path> option

Ed W lists at wildgooses.com
Sat Sep 4 14:34:59 UTC 2021


On 04/09/2021 12:07, Chris Green wrote:
> On Sat, Sep 04, 2021 at 11:29:32AM +0100, Ed W wrote:
>> On 04/09/2021 09:15, Chris Green wrote:
>>
>>> I was aiming to synchronise the lease file in /var between the two
>>> systems as well as the configuration.
>>>
>> Did you see my suggestion to cross post the events to each machine using 
>> a script? I replied in one 
>> of your other threads re this situation? I think you could make a simple/imperfect cluster setup
>> like this fairly easily? (good enough for a small home lan)
>>
> Yes, but I'm not quite clear what you mean by "cross post the events"?
> Do you mean something more than just synchronising the /var/lib/misc/dnsmasq.leases 
> file between the two systems?


Hi, yes, dnsmasq emits a dbus event when a lease is created and has a dbus method to add a lease to
it's db.

Both can be scripted (examples given), so you can effectively "do something" every time a lease is
handed out and poke the details of that lease into the other system *live*, ie it goes directly into
its in memory db (which eventually will filter out to the on disk db)

This gives you your optimal solution in that both machines have an in sync view of the lease table,
ie promoting the second machine will immediately know the state of all the leases handed out by the
first

I speculate (without proof) that it might even work "well enough" to have both machines online and
fighting to hand out dhcp leases... It's definitely *wrong*, but on a small network it might not
break...


> Anyway I think I'm slowly working my way to a reasonable way of doing
> this.  My latest idea changes things a little:-
>
> Run identical dnsmasq configurations on two systems, keep the
> configuration files and lease files synchronised.  Use
> --listen-address to tell dnsmasq to listen to an IP that is only
> configured on one of the systems.  Then, if that system dies, use 'ip
> addr add x.x.x.x eth0' to create the IP that dnsmasq will use on the
> backup system and all will be well.
>
> Will dnsmasq complain if the --listen-address doesn't exist?  If so I 
> can simply disable dnsmasq on the backup system (still synchronise
> files) and start it up as well as configure the IP when I need it.
>
> Can anyone see any major holes in this?


I think you can just have listen-address=0.0.0.0 on both machines?

You then need a "high availability" system to ensure that the IP only gets assigned to one of the
devices or the other... However, my opinion would be that for a small home network it would be "good
enough" that the machines ping each other and if one goes down, the other promotes itself?

eg consider the dns machine to be given out via DHCP as 192.168.22.1 and two real machines on
192.168.22.2 and 192.168.22.3, they each ping each other and if one is missing (or
$machine==master), the other promotes itself to master and grabs the 192.168.22.1 IP address

Now to do this properly you need to consider netsplits, ie where both machine *are* alive, but some
other reason prevents them seeing each other. In the trivial case above they will both promote
themselves to master. If you add in some (weird) way that both can see half the network then
problems occur. The "proper" solution is a third machine to act as a voting tie breaker, some
hardware to STONITH the dead note, etc, etc. However, I will risk derision by claiming that for dhcp
in a home network, a) a netsplit would be very occasional and b) it's easily cleaned up from by just
unplugging and replugging the affected machines, so really not worth the effort to properly implement...


Good luck!

Ed W

>




More information about the Dnsmasq-discuss mailing list