<div dir="ltr"><div dir="ltr">On Sat, Dec 31, 2022 at 11:28 AM Geert Stappers <<a href="mailto:stappers@stappers.nl">stappers@stappers.nl</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, Dec 29, 2022 at 05:34:24PM -0500, Jonathan Stafford wrote:<br>
> On Thu, Dec 22, 2022 at 3:46 PM Michael Smith <<a href="mailto:michael@kmaclub.com" target="_blank">michael@kmaclub.com</a>> wrote:<br>
> <br>
> > I run 2 instances of pihole (DNSmasq) on docker. Each run on their own<br>
> > IP address (macvlan) separate from the docker host. Their IP addresses<br>
> > are .2 and .3.<br>
> ><br>
> ><br>
> > The .2 host is primary and forwards upstream to 1.1.1.1. This container<br>
> > also holds all the hosts file info and handles DHCP+dynamic host DNS<br>
> > resolution.<br>
> ><br>
> > The .3 host is secondary and handles only DNS requests for the kids.<br>
> > This forwards upstream to 1.1.1.3. If a DNS request comes in for local<br>
> > domain info, it simply forwards those requests to .2 like this:<br>
> ><br>
> > server=/<a href="http://mydomain.com/192.168.101.2" rel="noreferrer" target="_blank">mydomain.com/192.168.101.2</a><br>
> > server=/101.168.192.in-addr.arpa/<a href="http://192.168.101.2" rel="noreferrer" target="_blank">192.168.101.2</a><br>
> ><br>
> ><br>
> > Combine with the tagging and now you can point any client to either<br>
> > upstream DNS:<br>
> ><br>
> > # Define DNS servers<br>
> > dhcp-option=option:dns-server,192.168.101.2<br>
> > dhcp-option=tag:kidsdevices,option:dns-server,192.168.101.3<br>
> ><br>
> > dhcp-host=0c:51:01:95:d3:36,set:kidsdevices # Ipad<br>
> > dhcp-host=58:41:4E:CD:D2:0A,set:kidsdevices # Iphone<br>
> ><br>
> <br>
> Thanks everybody for the discussion. I ended up doing something like what<br>
> Michael and Geert described and adding a second IP to my server and running<br>
> two instances of dnsmasq.<br>
> <br>
> The primary instance handles DHCP, uses 1.1.1.2 as its upstream, and tags a<br>
> handful of devices to use it for DNS:<br>
> <br>
> no-resolv<br>
> server=1.1.1.2<br>
> interface=lo<br>
> interface=eth0 # 10.1.1.32<br>
> bind-interfaces<br>
> dhcp-host=1c:0d:7d:13:9e:3e,set:cf1112<br>
> dhcp-option=option:dns-server,10.1.1.33<br>
> dhcp-option=tag:cf1112,option:dns-server,10.1.1.32<br>
> <br>
> The secondary instance is just doing DNS and using 1.1.1.3 as its upstream:<br>
> <br>
> no-resolv<br>
> server=1.1.1.3<br>
> interface=eth0:1 # 10.1.1.33<br>
> except-interface=lo<br>
> no-dhcp-interface=eth0:1<br>
> bind-interfaces<br>
> <br>
<br>
How are those solutions ( "docker" and "IP alias") started when the host<br>
reboots. Is the %i <br>
of <a href="https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2022q4/016771.html" rel="noreferrer" target="_blank">https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2022q4/016771.html</a><br>
being used?<br></blockquote><div><br></div><div>I am running dnsmasq on a Raspberry Pi that is mostly used to run rtl_433. No Docker installed and didn't feel like adding it as it seems to make things much more sluggish. I created the new interface with /etc/interfaces.d/eth0-dnsmasq:</div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_quote"><div>auto eth0:1</div></div><div class="gmail_quote"><div>allow-hotplug eth0:1</div></div><div class="gmail_quote"><div>iface eth0:1 inet static</div></div><div class="gmail_quote"><div> address 10.1.1.33</div></div><div class="gmail_quote"><div> netmask 255.0.0.0</div></div><div class="gmail_quote"><div> gateway 10.1.1.1</div></div></blockquote>`systemctl restart network` made it appear and it is automatically created/configured on reboot.<br><br><div>The second instance is using %i under the hood, yes, although I didn't realize what that was at the time. Looking at the init script I saw the INSTANCE variable and kind of stumbled my way backwards into using it. I don't recall the exact order I did things but I think the correct thing to do was `systemctl enable dnsmasq@family` which created /lib/systemd/system/dnsmasq@.service which is using %i:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>[Unit]</div><div>Description=dnsmasq (%i) - A lightweight DHCP and caching DNS server</div><div>Requires=network.target</div><div>Wants=nss-lookup.target</div><div>Before=nss-lookup.target</div><div>After=network.target</div></blockquote><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><br></div><div>[Service]</div><div>Type=forking</div><div>PIDFile=/run/dnsmasq/dnsmasq.%i.pid</div></blockquote></div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><br></div><div># Test the config file and refuse starting if it is not valid.</div><div>ExecStartPre=/etc/init.d/dnsmasq checkconfig "%i"</div></blockquote></div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><br></div></blockquote></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>...</div></blockquote><div><br></div><div>Then I created /etc/dnsmasq.family.conf and was able to `systemctl start dnsmasq@family`. So I have "dnsmasq" and "dnsmasq@family" instances running.</div><div><br></div><div><br></div></div>