How to configure Subnet Mask in DHCP options


#1

Hi

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 172.16.0.1/24 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.

Cheers

Leigh


#2

Here is little push.

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

NAME
       dnsmasq - A lightweight DHCP and caching DNS server.

SYNOPSIS
       dnsmasq [OPTION]...

DESCRIPTION
       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-
       name>|option6:<opt>|option6:<opt-name>],[<value>[,<value>]]
              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  192.168.4.4,  do  --dhcp-option=3,192.168.4.4  or --dhcp-option = option:router,
              192.168.4.4 and to set the time-server address to 192.168.0.4,  do  --dhcp-option  =  42,192.168.0.4  or  --dhcp-option  =
              option:ntp-server, 192.168.0.4 The special address 0.0.0.0 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

#3

Hi

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

Then finding this was key - https://manpages.debian.org/stretch/dnsmasq-base/dnsmasq.8.en.html

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

Thanks for the pointer :slight_smile:


#4

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