<div dir="ltr"><div data-smartmail="gmail_signature">We have an Ubuntu v16.04.5 server with dnsmasq v2.75. The server acts as a router for approximately 140 IP subnets and dnsmasq provides DHCP and DNS for those subnets. The server has two network interfaces, which are basically an "upstream" interface (eno1) that has routes out of the LAN and a "downstream" interface (enp2s0) that has an IP address in every subnet that is managed by dnsmasq.</div><div data-smartmail="gmail_signature"><br></div><div data-smartmail="gmail_signature">First, I'll describe the configuration of the server. Most of the downstream subnets are portions of <a href="http://172.18.0.0/16">172.18.0.0/16</a>. The /16 is split into halves, <a href="http://172.18.0.0/17">172.18.0.0/17</a> and <a href="http://172.18.128.0/17">172.18.128.0/17</a>. Then the lower half is split into many /24s (<a href="http://172.18.0.0/24">172.18.0.0/24</a>, <a href="http://172.18.1.0/24">172.18.1.0/24</a>, <a href="http://172.18.2.0/24">172.18.2.0/24</a>, and so on). The server's downstream interface then has the ".1" address of every subnet:<br><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div data-smartmail="gmail_signature">(some lines are grepped out to make this easier to read)</div><div data-smartmail="gmail_signature"><font face="monospace">3: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast state UP group default qlen 1000</font></div><div data-smartmail="gmail_signature"><font face="monospace">    inet <a href="http://10.139.100.1/24">10.139.100.1/24</a> brd 10.139.100.255 scope global enp2s0</font></div><div data-smartmail="gmail_signature"><font face="monospace">    inet <a href="http://10.139.200.1/23">10.139.200.1/23</a> brd 10.139.201.255 scope global enp2s0</font></div><div data-smartmail="gmail_signature"><font face="monospace">    inet <a href="http://10.43.10.1/24">10.43.10.1/24</a> brd 10.43.10.255 scope global enp2s0</font></div><div data-smartmail="gmail_signature"><font face="monospace">    inet <a href="http://10.43.6.1/24">10.43.6.1/24</a> brd 10.43.6.255 scope global enp2s0</font></div><div data-smartmail="gmail_signature"><font face="monospace">    inet <a href="http://10.43.12.1/24">10.43.12.1/24</a> brd 10.43.12.255 scope global enp2s0</font></div><div data-smartmail="gmail_signature"><font face="monospace">    inet <a href="http://10.43.16.1/24">10.43.16.1/24</a> brd 10.43.16.255 scope global enp2s0</font></div><div data-smartmail="gmail_signature"><font face="monospace">    inet <a href="http://10.43.17.1/24">10.43.17.1/24</a> brd 10.43.17.255 scope global enp2s0</font></div><div data-smartmail="gmail_signature"><font face="monospace">    inet <a href="http://172.18.0.1/24">172.18.0.1/24</a> brd 172.18.0.255 scope global enp2s0</font></div><div data-smartmail="gmail_signature"><font face="monospace">    inet <a href="http://172.18.1.1/24">172.18.1.1/24</a> brd 172.18.1.255 scope global enp2s0</font></div><div data-smartmail="gmail_signature"><font face="monospace">    inet <a href="http://172.18.2.1/24">172.18.2.1/24</a> brd 172.18.2.255 scope global enp2s0</font></div><div data-smartmail="gmail_signature"><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div data-smartmail="gmail_signature"><font face="monospace">< snip - every /24 of the lower /17 is setup this way ></font></div></blockquote></div><div data-smartmail="gmail_signature"><font face="monospace">    inet <a href="http://172.18.125.1/24">172.18.125.1/24</a> brd 172.18.125.255 scope global enp2s0</font></div><div data-smartmail="gmail_signature"><font face="monospace">    inet <a href="http://172.18.126.1/24">172.18.126.1/24</a> brd 172.18.126.255 scope global enp2s0</font></div><div data-smartmail="gmail_signature"><font face="monospace">    inet <a href="http://172.18.127.1/24">172.18.127.1/24</a> brd 172.18.127.255 scope global enp2s0</font></div><div data-smartmail="gmail_signature"><font face="monospace">    inet <a href="http://172.18.128.1/17">172.18.128.1/17</a> brd 172.18.255.255 scope global enp2s0</font></div><div data-smartmail="gmail_signature"><font face="monospace">    inet6 fe80::225:90ff:fed6:368a/64 scope link</font></div></blockquote><div data-smartmail="gmail_signature"><br></div><div data-smartmail="gmail_signature">In <font face="monospace">/etc/default/dnsmasq</font>, we enable the daemon and set <font face="monospace">CONFIG_DIR=/etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new</font>. The main dnsmasq configuration is in this file:</div><div data-smartmail="gmail_signature"><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div data-smartmail="gmail_signature"><font face="monospace"># /etc/dnsmasq.d/dev-router</font></div><div data-smartmail="gmail_signature"><font face="monospace">local=/<a href="http://dev.editshare.com/">dev.editshare.com/</a></font></div><div data-smartmail="gmail_signature"><font face="monospace">interface=enp2s0</font></div><div data-smartmail="gmail_signature"><font face="monospace">domain=<a href="http://dev.editshare.com">dev.editshare.com</a></font></div><div data-smartmail="gmail_signature"><font face="monospace">host-record=<a href="http://dev.editshare.com">dev.editshare.com</a>,176.58.116.220</font></div><div data-smartmail="gmail_signature"><font face="monospace">auth-server=dev-router.editshare.boston,eno1</font></div><div data-smartmail="gmail_signature"><font face="monospace">auth-zone=<a href="http://dev.editshare.com">dev.editshare.com</a>,enp2s0,176.58.116.220</font></div><div data-smartmail="gmail_signature"><font face="monospace">server=/<a href="http://qa-ad.dev.editshare.com/172.18.3.99">qa-ad.dev.editshare.com/172.18.3.99</a></font></div><div data-smartmail="gmail_signature"><font face="monospace">dhcp-option=option:domain-name,"<a href="http://dev.editshare.com">dev.editshare.com</a> editshare.boston"</font></div><div data-smartmail="gmail_signature"><font face="monospace">dhcp-option=option:domain-search,<a href="http://dev.editshare.com">dev.editshare.com</a>,editshare.boston</font></div><div data-smartmail="gmail_signature"><font face="monospace">dhcp-hostsdir=/etc/dhcp-hosts</font></div><div data-smartmail="gmail_signature"><font face="monospace">dhcp-optsdir=/etc/dhcp-opts</font></div><div data-smartmail="gmail_signature"><font face="monospace">hostsdir=/etc/static-hosts</font></div><div data-smartmail="gmail_signature"><font face="monospace">expand-hosts</font></div></blockquote><div data-smartmail="gmail_signature"><font face="monospace"><br></font></div><div data-smartmail="gmail_signature"><font face="arial, sans-serif">And then we put additional configuration (</font><font face="monospace">dhcp-hosts</font><font face="arial, sans-serif">, </font><font face="monospace">dhcp-range</font><font face="arial, sans-serif">, and so on) into separate files per subnet or supernet. For example, we can examine the <a href="http://172.18.15.0/24">172.18.15.0/24</a> subnet:<br><br></font></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div data-smartmail="gmail_signature"><font face="monospace"># /etc/dnsmasq.d/172.18.0.0-16 </font></div><div data-smartmail="gmail_signature"><font face="monospace">dhcp-range=172.18.135.0,172.18.255.255,255.255.128.0</font></div><div data-smartmail="gmail_signature"><font face="monospace">dhcp-range=172.18.0.0,static,255.255.255.0</font></div><div data-smartmail="gmail_signature"><font face="monospace">dhcp-range=172.18.1.0,static,255.255.255.0</font></div><div data-smartmail="gmail_signature"><font face="monospace">dhcp-range=172.18.2.0,static,255.255.255.0</font></div><div data-smartmail="gmail_signature"><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div data-smartmail="gmail_signature"><font face="monospace">< snip - every /24 in this range is setup this way ></font></div></blockquote></div><div data-smartmail="gmail_signature"><font face="monospace">dhcp-range=172.18.14.0,static,255.255.255.0</font></div><div data-smartmail="gmail_signature"><font face="monospace">dhcp-range=172.18.15.0,static,255.255.255.0</font></div><div data-smartmail="gmail_signature"><font face="monospace">dhcp-range=172.18.16.0,static,255.255.255.0</font></div><div data-smartmail="gmail_signature"><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div data-smartmail="gmail_signature"><font face="monospace">< snip - every /24 in this range is setup this way ></font></div></blockquote></div><div data-smartmail="gmail_signature"><font face="monospace">dhcp-range=172.18.125.0,static,255.255.255.0</font></div><div data-smartmail="gmail_signature"><font face="monospace">dhcp-range=172.18.126.0,static,255.255.255.0</font></div><div data-smartmail="gmail_signature"><font face="monospace">dhcp-range=172.18.127.0,static,255.255.255.0</font></div></blockquote><div data-smartmail="gmail_signature"><font face="arial, sans-serif"><br></font></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div data-smartmail="gmail_signature"><font face="arial, sans-serif">(some </font><font face="monospace">dhcp-hosts</font><font face="arial, sans-serif"> are omitted here to make this easier to read)</font></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div data-smartmail="gmail_signature"><font face="monospace"># /etc/dhcp-hosts/172.18.15.0-24</font></div><div data-smartmail="gmail_signature"><font face="monospace">00:c0:b7:f1:0f:65,rack7-pdu1</font></div><div data-smartmail="gmail_signature"><font face="monospace">00:c0:b7:f1:a3:71,rack7-pdu2</font></div></blockquote><div data-smartmail="gmail_signature"><br></div><div data-smartmail="gmail_signature"><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div data-smartmail="gmail_signature"><span style="font-family:arial,sans-serif">(some </span><font face="monospace">static-hosts</font><span style="font-family:arial,sans-serif"> are omitted here to make this easier to read)</span><br></div></blockquote></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div data-smartmail="gmail_signature"><font face="monospace"># /etc/static-hosts/172.18.15.0-24</font></div><div data-smartmail="gmail_signature"><font face="monospace">172.18.15.106 rack7-pdu1</font></div><div data-smartmail="gmail_signature"><font face="monospace">172.18.15.107 rack7-pdu2</font></div></blockquote><div style="font-family:monospace"><br></div><div style=""><font face="arial, sans-serif">(From this point, I'll refer to <a href="http://172.18.15.0/24">172.18.15.0/24</a> as "the 15 subnet.")</font></div><div style=""><font face="arial, sans-serif"><br></font></div><div style=""><font face="arial, sans-serif">With the above configuration in place, when rack7-pdu1 is connected to the network, it is given the IP address <a href="http://172.18.15.106/24">172.18.15.106/24</a>, the default gateway address 172.18.15.1, and the DNS server address 172.18.15.1. That's the normal behavior that we expect from this configuration, which has been in place for a few years.</font></div><br><div><font face="arial, sans-serif">Now I'm introducing changes to that config: We need to decommission this server as a router and as a DHCP and DNS server, and those services will be migrated to other servers. The first step of our migration workflow is to move the default gateway addresses to another router in the network while continuing to use dnsmasq on the current server for DHCP and DNS. The 15 subnet contains relatively few hosts and is not sensitive to disruptions, so I am testing the changes for only that subnet until we are satisfied that this process works. I removed <a href="http://172.18.15.1/24">172.18.15.1/24</a> from </font><font face="monospace">enp2s0</font><font face="arial, sans-serif"> and added it to an interface of a router upstream. After doing that, we could no longer reach rack7-pdu1 at <a href="http://172.18.15.106/24">172.18.15.106/24</a>. We suspected that the reason could be that the client wasn't being given a default gateway by the DHCP server because the server was no longer directly attached to the 15 subnet, so we tried using </font><font face="monospace">dhcp-option</font><font face="arial, sans-serif"> to force including </font><font face="monospace">option:router</font><font face="arial, sans-serif"> in the DHCP response. We tried this four different ways but could not produce the desired outcome:</font></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">#1: set the tag for a </span><font face="monospace">dhcp-range</font><span style="font-family:arial,sans-serif">, apply the tag to </span><font face="monospace">dhcp-option</font></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="monospace"># /etc/dnsmasq.d/172.18.0.0-16</font></div><div><font face="monospace">dhcp-range=set:172.18.15.0-24,172.18.15.0,static,255.255.255.0<br>dhcp-option=tag:172.18.15.0-24,option:router,172.18.15.1</font><br></div></blockquote><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">#2: </span>set the tag for one <font face="monospace">dhcp-host</font>, apply the tag to <font face="monospace">dhcp-range</font> and <font face="monospace">dhcp-opts</font></div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="monospace"># /etc/dnsmasq.d/172.18.0.0-16</font></div><div><font face="monospace">dhcp-range=tag:test,172.18.15.0,static,255.255.255.0<br># /etc/dhcp-hosts/172.18.15.0-24<br></font></div><div><font face="monospace">00:c0:b7:f1:0f:65,set:test,rack7-pdu1<br># /etc/dhcp-opts/172.18.15.0-24<br></font></div><div><font face="monospace">tag:test,option:router,172.18.15.1<br># /etc/static-hosts/172.18.15.0-24<br></font></div><div><font face="monospace">172.18.15.106 rack7-pdu1</font></div></blockquote><div><br></div>#3: set the tag for a <font face="monospace">dhcp-range</font>, apply the tag to <font face="monospace">dhcp-range</font> and <font face="monospace">dhcp-opts</font></div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="monospace"># /etc/dnsmasq.d/172.18.0.0-16</font></div><div><font face="monospace">dhcp-range=tag:test,set:test,172.18.15.0,static,255.255.255.0<br># /etc/dhcp-hosts/172.18.15.0-24</font></div><div><font face="monospace">00:c0:b7:f1:0f:65,rack7-pdu1<br># /etc/dhcp-opts/172.18.15.0-24</font></div><div><font face="monospace">tag:test,option:router,172.18.15.1<br># /etc/static-hosts/172.18.15.0-24</font></div><div><font face="monospace">172.18.15.106 rack7-pdu1</font><br></div></blockquote><br></div><div>#4: set the tag for one <font face="monospace">dhcp-host</font>, apply the tag to <font face="monospace">dhcp-opts</font></div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="monospace"># /etc/dnsmasq.d/172.18.0.0-16</font></div><div><font face="monospace">dhcp-range=172.18.15.0,static,255.255.255.0<br># /etc/dhcp-hosts/172.18.15.0-24</font></div><div><font face="monospace">00:c0:b7:f1:0f:65,set:test,rack7-pdu1<br># /etc/dhcp-opts/172.18.15.0-24</font></div><div><font face="monospace">tag:test,option:router,172.18.15.1<br># /etc/static-hosts/172.18.15.0-24</font></div><div><font face="monospace">172.18.15.106 rack7-pdu1</font><br></div></blockquote></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">Before each test, I used </span><font face="monospace">dhcp_release</font><span style="font-family:arial,sans-serif"> to revoke the client's existing lease. As we watched the </span><font face="monospace">dnsmasq.leases</font><span style="font-family:arial,sans-serif"> file, we observed the lease being removed and then approximately halfway through the lease period, we observed dnsmasq give a new lease to the client with an</span><span style="font-family:arial,sans-serif"> IP address from our "catch-all" IP address pool, between 172.18.135.0 and 172.18.255.255 instead of giving it 172.18.15.106 as expected. When we checked the log, we saw that the 15 subnet was not being logged as an "available DHCP subnet:"</span></div><div><font face="arial, sans-serif"><br></font></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="arial, sans-serif">< snip - every /24 between <a href="http://172.18.18.0/24">172.18.18.0/24</a> and <a href="http://172.18.127.0/24">172.18.127.0/24</a> was listed before this ></font></div><div><font face="monospace">Oct 19 16:36:48 dnsmasq-dhcp[26972]: 993790843 available DHCP subnet: <a href="http://172.18.17.0/255.255.255.0">172.18.17.0/255.255.255.0</a></font></div><div><font face="monospace">Oct 19 16:36:48 dnsmasq-dhcp[26972]: 993790843 available DHCP subnet: <a href="http://172.18.16.0/255.255.255.0">172.18.16.0/255.255.255.0</a></font></div><div><font face="monospace">Oct 19 16:36:48 dnsmasq-dhcp[26972]: 993790843 available DHCP subnet: <a href="http://172.18.14.0/255.255.255.0">172.18.14.0/255.255.255.0</a></font></div><div><font face="monospace">Oct 19 16:36:48 dnsmasq-dhcp[26972]: 993790843 available DHCP subnet: <a href="http://172.18.13.0/255.255.255.0">172.18.13.0/255.255.255.0</a></font></div><div><span style="font-family:arial,sans-serif">< snip - every /24 between <a href="http://172.18.12.0/24">172.18.12.0/24</a> and <a href="http://172.18.0.0/24">172.18.0.0/24</a> was listed after this ></span></div></blockquote><font face="arial, sans-serif"><br></font><div><font face="arial, sans-serif">Again we suspected that this must be due to the server not being connected to <a href="http://172.18.15.0/24">172.18.15.0/24</a>. We tried adding <a href="http://172.18.15.254/24">172.18.15.254/24</a> to </font><font face="monospace">enp2s0</font><font face="arial, sans-serif"> along with configuration #3, but the outcome was unchanged.</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">We kept reading the docs and searching for advice, and we found the </font><font face="monospace">shared-network</font><font face="arial, sans-serif"> option that was added in v2.81. According to the docs, this seems like it could solve our problem. Since we are using a relatively old version of Ubuntu and we can't upgrade it at this time, we downloaded the source for dnsmasq v2.87, compiled it on the server (with the only modification being </font><font face="monospace">COPTS=’-DHAVE_DBUS -DHAVE_DNSSEC’</font><font face="arial, sans-serif">), and replaced the v2.75 binary with the v2.87 binary. We tested both </font><font face="monospace">shared-network</font><font face="arial, sans-serif"> syntaxes independently:</font></div><div><font face="arial, sans-serif"><br></font></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="monospace"># first attempt: <interface>,<network-address></font></div><div><font face="monospace">shared-network=enp2s0,172.18.15.0</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"># second attempt: <relay-address>,<network-address></font></div><div><font face="monospace">shared-network=172.18.128.1,172.18.15.0</font></div></blockquote><font face="arial, sans-serif"><br></font><div><span style="font-family:arial,sans-serif">But the outcome was unchanged in both cases: The lease given to rack7-pdu1 was not for 172.18.15.106. It was an address from the DHCP pool in <a href="http://172.18.128.0/17">172.18.128.0/17</a>.</span><font face="arial, sans-serif"><br></font></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">I have also tried adding the IP address to the dhcp-hosts config like so:</span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:monospace">00:c0:b7:f1:0f:65,set:test,172.18.15.106,rack7-pdu1</span><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">But that also had no effect.</span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><font face="arial, sans-serif">At this point, I'm out of ideas. There must be something in my configuration that isn't correct, but I can't figure out what it is. The configuration syntax test always passes unless I've made an obvious typo. Can anyone offer some help, please?</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">-Rich</font></div></div>