[Dnsmasq-discuss] dhcpd3 to dnsmasq : grouping using the network-id

Simon Kelley simon at thekelleys.org.uk
Tue Feb 2 13:11:45 GMT 2010


Simone wrote:
> Hi,
> 
>  I'm trying to translate this piece of dhcpd3-server's  configuration
> for dnsmasq but I'm quite confuse about the syntax to use for grouping
> with ``network-id``.
> 
> this is the first part of my configuration ::
> 
>     subnet 192.168.11.0 netmask 255.255.255.0 {
>         range 192.168.11.200 192.168.11.250;
>         option domain-name-servers 192.168.11.254;
>         option broadcast-address 192.168.11.255;
>         option routers 192.168.11.253;
>         next-server 192.168.11.253;
>         get-lease-hostnames true;
>         option subnet-mask 255.255.255.0;
>         option root-path "/opt/ltsp/i386";
>         if substring( option vendor-class-identifier, 0, 9 ) = "PXEClient" {
>             filename "/ltsp/i386/pxelinux.0";
>         } else {
>             filename "/ltsp/i386/nbi.img";
>         }
>     }
> 
> I translated it to :
> 
>     dhcp-range=192.168.11.200,192.168.11.250,255.255.255.0,8h
>     dhcp-option=6,192.168.11.254  # dns
>     dhcp-option=3,192.168.11.253  # gw
>     dhcp-option=44,192.168.11.253 # wins
>     next-server 192.168.11.253;
>     dhcp-option=17,"/opt/ltsp/i386"
> 
>     # PXE / Etherboot tagging
>     dhcp-vendorclass=pxe,PXEClient
>     dhcp-vendorclass=eth,Etherboot
> 
>     # assigning (eventually) different servers selecting by tag
>     
> 
>     dhcp-boot=net:pxe,/ltsp/i386/pxelinux.0,ltsp-server,192.168.11.253
>     dhcp-boot=net:eth,/ltsp/i386/pxelinux.0,ltsp-server, 192.168.11.253
>     # other
>     dhcp-boot=/ltsp/i386/nbi.img,ltsp-server,192.168.11.253
> 
> Here starts the problematic part of the dhcpd3-server config, I have
> multiple occurrances of selection per-mac :
> 
>     host ltsp001 {
>       hardware ethernet 00:0c:30:20:b3:13;
>       fixed-address 192.168.11.101;
>       next-server 192.168.11.253;      # next-server #1
>     }
> 
>     host ltsp002 {
>       hardware ethernet 00:0c:10:11:d1:23;
>       fixed-address 192.168.11.102;
>       next-server 192.168.11.253;      # next-server #1
>     }
> 
>     host ltsp003 {
>       hardware ethernet 00:0c:10:50:c3:12;
>       fixed-address 192.168.11.103;
>       next-server 192.168.11.252;      # next-server #2
>     }
> 
>     host ltsp003 {
>       hardware ethernet 00:0c:40:30:b4:15;
>       fixed-address 192.168.11.104;
>       next-server 192.168.11.252;      # next-server #2
>     }
> 
> 
> I reserved ip for the hosts defined above :
> 
>     # Setting static ip addresses
>     dhcp-host=00:0c:30:20:b3:13,192.168.11.101,ltsp001
>     dhcp-host=00:0c:10:11:d1:23,192.168.11.102,ltsp002
>     dhcp-host=00:0c:10:50:c3:12,192.168.11.103,ltsp003
>     dhcp-host=00:0c:40:30:b4:15,192.168.11.104,ltsp004
> 
> But I don't know how can I assign multiple mac addresses to a single
> network-id ...
> I read in the man page that I can use this syntax( valid for a single mac):
> 
>   dhcp-mac=<tag>, mac
> 
> So I tried to group as follows :
> 
>     # Grouping per mac-address, creating 2 different "network-id"
>     # network-id: ltspgroup1
>     dhcp-mac=ltspgroup1,00:0c:30:20:b3:13
>     dhcp-mac=ltspgroup1,00:0c:10:11:d1:23
>     # network-id: ltspgroup2
>     dhcp-mac=ltspgroup2,00:0c:10:50:c3:12
>     dhcp-mac=ltspgroup2,00:0c:40:30:b4:15
> 
> And to set different next-server and tftp server by network-id:
> 
>     # Setting different "next-server" filtering by "network-id" tags
>     dhcp-boot=net:ltspgroup1,/ltsp/i386/pxelinux.0,ltsp-server,192.168.11.253
>     dhcp-boot=net:ltspgroup2,/ltsp/i386/pxelinux.0,ltsp-server,192.168.11.252
> 
>     # Setting ip of the tftp srever
>     dhcp-option=net:ltspgroup1,option:193,192.168.11.253
>     dhcp-option=net:ltspgroup2,option:193,192.168.11.252
> 
> But I really don't know if I am right. What is the correct syntax?
> 
> Thank you in advance,
>  Simone
> 

You need to take advantage of the ability to give more than one tag in 
dhcp-boot and dhcp-option. The tags are ANDed together, so the line is 
only valid if both tags exist.

dhcp-boot=net:pxe,net:ns1,/ltsp/i386/pxelinux.0,ltsp-server,192.168.11.252
dhcp-boot=net:eth,net:ns1,/ltsp/i386/pxelinux.0,ltsp-server,192.168.11.252

dhcp-boot=net:pxe,net:ns2,/ltsp/i386/pxelinux.0,ltsp-server,192.168.11.253
dhcp-boot=net:eth,net:ns2,/ltsp/i386/pxelinux.0,ltsp-server,192.168.11.253

And then set either tag ns1 or tag ns2, depending on which host is in use

dhcp-host=00:0c:30:20:b3:13,192.168.11.101,ltsp001,net:ns1
dhcp-host=00:0c:10:11:d1:23,192.168.11.102,ltsp002,net:ns1
dhcp-host=00:0c:10:50:c3:12,192.168.11.103,ltsp003,net:ns2
dhcp-host=00:0c:40:30:b4:15,192.168.11.104,ltsp004,net:ns2



As an aside, I'm aware that the whole netid thing is very confusing. The 
problem is that the system has grown in complexity and generality over 
the years, and the nomenclature and documentation have lagged behind.

For the next release of dnsmasq, I'm working on a wholesale update: The 
"netid" word has gone, and they are just called "tags". The syntax has 
been made much clearer, everywhere where a tag is to be set, it appears 
as "set:<tag>" and everywhere the existance of a tag is used as a 
conditional, it appears as "tag:<tag>". (The old syntax is still 
recognised, so I won't break existing config files)




HTH


Simon.



More information about the Dnsmasq-discuss mailing list