How to configure Subnet Mask in DHCP options



Noob here, I’m just getting to grips with Linux and am finding the Pi a great little machine to work with. I’m a network engineer so obviously, this app caught my eye. My home network is so a subnet of the 172.x.x.x private range.

I’m using the built-in DHCP server but that obviously uses the mask for the whole 172.x.x.x range, whilst this is ok, it works, but it does make network discoveries and scans take forever. I’ve looked but can’t find how to change the subnet mask in the DHCP options, can one of you nice people point me in the right direction.




Here is little push.

$ man dnsmasq
DNSMASQ(8)                                               System Manager's Manual                                              DNSMASQ(8)

       dnsmasq - A lightweight DHCP and caching DNS server.

       dnsmasq [OPTION]...

       dnsmasq  is  a  lightweight  DNS, TFTP, PXE, router advertisement and DHCP server. It is intended to provide coupled DNS and DHCP
       service to a LAN.

       -O,     --dhcp-option=[tag:<tag>,[tag:<tag>,]][encap:<opt>,][vi-encap:<enterprise>,][vendor:[<vendor-class>],][<opt>|option:<opt-
              Specify  different  or extra options to DHCP clients. By default, dnsmasq sends some standard options to DHCP clients, the
              netmask and broadcast address are set to the same as the host running dnsmasq, and the DNS server and  default  route  are
              set  to  the address of the machine running dnsmasq. (Equivalent rules apply for IPv6.) If the domain name option has been
              set, that is sent.  This configuration allows these defaults to be overridden, or other options specified. The option,  to
              be sent may be given as a decimal number or as "option:<option-name>" The option numbers are specified in RFC2132 and sub‐
              sequent RFCs. The set of option-names known by dnsmasq can be discovered by running "dnsmasq --help dhcp".   For  example,
              to  set  the  default  route  option  to,  do  --dhcp-option=3,  or --dhcp-option = option:router,
     and to set the time-server address to,  do  --dhcp-option  =  42,  or  --dhcp-option  =
              option:ntp-server, The special address is taken to mean "the address of the machine running dnsmasq".

$ dnsmasq --help dhcp
Known DHCP options:
  1 netmask
  2 time-offset
  3 router
  6 dns-server

echo 'dhcp-option=option:netmask,<PUT_YOUR_SUBNETMASK_HERE>' | sudo tee /etc/dnsmasq.d/11-pihole-dhcp-subnet.conf

sudo service dnsmasq restart



Thanks for the pointer, understanding that dnsmasq is what underpins Pi_Hole was the main stumbling block, very noob!

Then finding this was key -

dnsmasq takes the default gateway from the ifconfig and it was wrong there so have fixed that instead.

Thanks for the pointer :slight_smile:


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.