DHCP in dual subnet setup

Hi community,

The server I have Pi-hole installed on has two network interfaces: 192.168.1.0/24 and 192.168.2.0/24. I'd like it to work as DHCP server for both networks, providing the addresses from respective ranges. I know how to do that in DNSMASQ, but haven't found any obvious option in Pi-hole GUI. Can anyone please send me to the right direction?

In Settings page, DHCP tab:

But you can only set for one Interface.

Yes, I've seen that. What Pi-hole is using for DHCP behind the hood? Would it be possible to update those configs manually to support this scenario?

dnsmasq config files, more precisely: /etc/dnsmasq.d/02-pihole-dhcp.conf, but the files are automatically populated by Pi-hole web interface. Changes will be lost.

1 Like

Thank you! Is there any way to add an extra config file for this scenario?

I havent tried it myself and there was no reply on below suggestion that I think could work:

Tail the logs live to see whats happening when you connect a device to either segments:

sudo tail -F /var/log/pihole/pihole.log | grep dnsmasq-dhcp

EDIT: Oh I noticed you'd might want to advertise a different router IP for the second subnet.
Then it should be below if eth1 were the second interface name ... as an example:

$ sudo nano /etc/dnsmasq.d/99-my-dhcp.conf
# Subnet network2.dehakkelaar.nl
domain=network2.dehakkelaar.nl,192.168.2.0/24,local
dhcp-range=eth1,192.168.2.50,192.168.2.250,24h
dhcp-option=eth1,option:router,192.168.2.1
1 Like

thanks! Will try and let you know

1 Like

I created a virtual eth1 dummy interface to test :wink:

$ sudo modprobe dummy
$
$ lsmod
Module                  Size  Used by
dummy                  16384  0
$ sudo ip link add eth1 type dummy
$
$ sudo ip address add 192.168.2.2/24 dev eth1
$
$ sudo ip link set eth1 up
$
$ ip -br -4 address show scope global
eth0             UP             10.0.0.2/24
eth1             UNKNOWN        192.168.2.2/24
$ sudo pihole-FTL dhcp-discover
Scanning all your interfaces for DHCP servers
Timeout: 10 seconds

* Received 327 bytes from eth1:192.168.2.2
  Offered IP address: 192.168.2.183
  Server IP address: 192.168.2.2
  Relay-agent IP address: N/A
  BOOTP server: (empty)
  BOOTP file: (empty)
  DHCP options:
   Message type: DHCPOFFER (2)
   server-identifier: 192.168.2.2
   lease-time: 86400 ( 1d )
   renewal-time: 43200 ( 12h )
   rebinding-time: 75600 ( 21h )
   netmask: 255.255.255.0
   broadcast: 192.168.2.255
   domain-name: "network2.dehakkelaar.nl"
   router: 192.168.2.1
   dns-server: 192.168.2.2
   --- end of options ---

* Received 318 bytes from eth0:10.0.0.2
  Offered IP address: 10.0.0.33
  Server IP address: 10.0.0.2
  Relay-agent IP address: N/A
  BOOTP server: (empty)
  BOOTP file: (empty)
  DHCP options:
   Message type: DHCPOFFER (2)
   server-identifier: 10.0.0.2
   lease-time: 86400 ( 1d )
   renewal-time: 43200 ( 12h )
   rebinding-time: 75600 ( 21h )
   netmask: 255.255.255.0
   broadcast: 10.0.0.255
   domain-name: "home.dehakkelaar.nl"
   dns-server: 10.0.0.2
   router: 10.0.0.1
   --- end of options ---

DHCP packets received on interface eth1: 1
DHCP packets received on interface lo: 0
DHCP packets received on interface eth0: 1
1 Like

Legend!

1 Like

Other DHCP server options that can be advertised:

$ pihole-FTL --list-dhcp4
Known DHCP options:
  1 netmask
  2 time-offset
  3 router
  6 dns-server
  7 log-server
  9 lpr-server
 13 boot-file-size
 15 domain-name
 16 swap-server
 17 root-path
 18 extension-path
 19 ip-forward-enable
 20 non-local-source-routing
 21 policy-filter
 22 max-datagram-reassembly
 23 default-ttl
 26 mtu
 27 all-subnets-local
 31 router-discovery
 32 router-solicitation
 33 static-route
 34 trailer-encapsulation
 35 arp-timeout
 36 ethernet-encap
 37 tcp-ttl
 38 tcp-keepalive
 40 nis-domain
 41 nis-server
 42 ntp-server
 44 netbios-ns
 45 netbios-dd
 46 netbios-nodetype
 47 netbios-scope
 48 x-windows-fs
 49 x-windows-dm
 58 T1
 59 T2
 60 vendor-class
 64 nis+-domain
 65 nis+-server
 66 tftp-server
 67 bootfile-name
 68 mobile-ip-home
 69 smtp-server
 70 pop3-server
 71 nntp-server
 74 irc-server
 77 user-class
 80 rapid-commit
 93 client-arch
 94 client-interface-id
 97 client-machine-id
100 posix-timezone
101 tzdb-timezone
108 ipv6-only
119 domain-search
120 sip-server
121 classless-static-route
125 vendor-id-encap
150 tftp-server-address
255 server-ip-address

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