[Dnsmasq-discuss] problem distributing dhcp-option to certain net: hosts

Brent Cook bcook at bpointsys.com
Mon May 22 20:18:37 BST 2006


On Monday 22 May 2006 13:09, Simon Kelley wrote:
> Brent Cook wrote:
> > Hi all,
> >
> > What I am trying to do is netboot a few different types of machines. I'm
> > allowing dnsmasq to identify different machines by the MAC address
> > prefix. For instance:
> >
> > dhcp-host=00:50:C2:*:*:*,net:pe-xes
> > dhcp-option=net:pe-xes,17,"/srv/nfsroot/powerpc"
> > dhcp-boot=net:pe-xes,kernel-xes,build,192.168.2.1
> >
> > The problem is that the 'dhcp-option' specification does not work. When a
> > machine gets a DHCP reply, option 17 is not passed. If I change the
> > dhcp-option to not check net: option, option 17 _is_ passed:
>
> Do you have a more specific dhcp-host line which matches this host?

No, it is the only one. The match rule works for the dhcp-boot line, just not 
the dhcp-option line.

> dnsmasq will only find one dhcp-host line, so if there's another one
> matching the whole MAC address or hostname or similar, then it will use
> that, and not the one you show.
>
> To get round this, use the dhcp-mac directive: replace your dhcp-hsot
> line with
>
> dhcp-mac=pe-xes,00:50:C2:*:*:*
>

I got it to work with the following:

dhcp-host=00:50:C2:*:*:*,net:pe-xes
dhcp-option=pe-xes,17,"/srv/nfsroot/powerpc"
dhcp-boot=net:pe-xes,kernel-xes,build,192.168.2.1

Looking at the man page again, it appears that this is consistent with the 
documentation:

dhcp-option=[<network-id>,[<network-id>,]][vendor:<vendor-class>]<opt>,
[<value>[,<value>]]

dhcp-boot=[net:<network-id>,]<filename>,[<servername>[,<server address>]]

So, the only problem here was that net: is not required consistently by 
different dnsmasq options. So, dhcp-boot parses off the 'net:' part, and 
dhcp-option literally sees 'net:pe-xes', which has no matching rule. I might 
suggest allowing an optional and ignored net: prefix when a network-id is 
used to avoid this confusion in the future, as in the following patch. I 
don't care either way, now that I know what the issue is.

Thanks
 - Brent

diff -urN dnsmasq-2.31/src/option.c dnsmasq-2.31.new/src/option.c
--- dnsmasq-2.31/src/option.c   2006-04-24 11:48:45.000000000 -0500
+++ dnsmasq-2.31.new/src/option.c       2006-05-22 14:14:48.000000000 -0500
@@ -1266,7 +1266,10 @@
                      else
                        {
                          new->netid = safe_malloc(sizeof (struct 
dhcp_netid));
-                         new->netid->net = safe_string_alloc(arg);
+                         if (strstr(arg, "net:") == arg)
+                           new->netid->net = safe_string_alloc(arg+4);
+                         else
+                           new->netid->net = safe_string_alloc(arg);
                          new->netid->next = np;
                          np = new->netid;
                        }



More information about the Dnsmasq-discuss mailing list