Score:0

dnsmasq: serve DHCP on bridge whose IP is out of subnet

in flag

I want to use dnsmasq to serve DHCP on a Linux bridge:

  • only one VM is expected to connect to the bridge
  • the VM's MAC is fixed
  • VM should get a static IP via DHCP
  • the bridge itself should not take any IP from the subnet (but it's ok for it to take a dummy IP like 169.254.x.x/16)

Below is the config I'm using:

port=0
bind-interfaces
interface=br0
dhcp-range=10.0.0.2,static,255.255.0.0
dhcp-host=52:54:00:d1:82:c4,10.0.0.2,infinite

The problem is, it seems to me that I have to give the bridge an IP within the subnet (like 10.0.0.1/16) to make the whole thing work. If I don't specify any IP on the bridge, or just specify a dummy IP (like 169.254.x.x/16), my VM would not get any IP from DHCP.

So is there any dnsmasq option/flag I can leverage with to make this work? Thanks a lot!

in flag
Can you add the output of `ip add dev br0`?
Score:0
in flag

DHCP does require local subnet communication between client and server.

Initial DISCOVER, OFFER, REQUEST and ACK is done between 0.0.0.0 and 255.255.255.255, but the server does respond from its own IP. Any renewal is however unicast directly to server IP.

So what you want to do is a bit out of spec, with that said it might be possible with an extra level of DHCP relay.

fengye87 avatar
in flag
I can actually make it work with the help of a [Golang DHCP lib](https://github.com/insomniacslk/dhcp). But the way I use it is a bit hacky and may not cover all corner cases. Just wondering if dnsmasq has a decent way to support this scenario.
Score:0
in flag

After digging into dnsmasq's source code, the shared network feature seems to work for me. The added shared-network=... line did the trick, though I'm not 100% sure this is the correct/safe way to go.

port=0
bind-interfaces
interface=br0
shared-network=br0,10.0.0.101
dhcp-range=10.0.0.101,static,255.255.0.0
dhcp-host=52:54:00:d1:82:c4,10.0.0.101,infinite
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.