Want to launch dnsmasq ony when Thunderbolt Ethernet is active dnsmasq is installed using homebrew. Currently dnsmasq is spamming my system.log with messages like this:

Sep 26 18:22:46 Laptop com.apple.xpc.launchd[1] (homebrew.mxcl.dnsmasq[14526]): Service exited with abnormal code: 2
Sep 26 18:22:46 Laptop com.apple.xpc.launchd[1] (homebrew.mxcl.dnsmasq): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Sep 26 18:22:56 Laptop com.apple.xpc.launchd[1] (homebrew.mxcl.dnsmasq[14527]): Service exited with abnormal code: 2
Sep 26 18:22:56 Laptop com.apple.xpc.launchd[1] (homebrew.mxcl.dnsmasq): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Sep 26 18:23:06 Laptop com.apple.xpc.launchd[1] (homebrew.mxcl.dnsmasq[14528]): Service exited with abnormal code: 2
Sep 26 18:23:06 Laptop com.apple.xpc.launchd[1] (homebrew.mxcl.dnsmasq): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Sep 26 18:23:16 Laptop com.apple.xpc.launchd[1] (homebrew.mxcl.dnsmasq[14529]): Service exited with abnormal code: 2
Sep 26 18:23:16 Laptop com.apple.xpc.launchd[1] (homebrew.mxcl.dnsmasq): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.


because i told dnsmasq to use only the Thunderbolt Ethernet adapter and when this adapter is not active, dnsmasq cannot find it, so it cannot start the service.

I want to run the dnsmasq service ONLY when the Thunderbolt Ethernet adapter is active. I CANNOT run it on all interfaces.

My current plist looks like this:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
  &lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;homebrew.mxcl.dnsmasq&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
      &lt;string&gt;/usr/local/opt/dnsmasq/sbin/dnsmasq&lt;/string&gt;
      &lt;string&gt;--keep-in-foreground&lt;/string&gt;
      &lt;string&gt;-C&lt;/string&gt;
      &lt;string&gt;/usr/local/etc/dnsmasq.conf&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;Requires&lt;/key&gt;
    &lt;array&gt;
      &lt;string&gt;Network&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;KeepAlive&lt;/key&gt;
    &lt;true/&gt;
  &lt;/dict&gt;
&lt;/plist&gt;


I cannot find any documentation on how to start dnsmasq ONLY when a certain network adapter is active.
Any ideas?
Not possible....

From https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/Introduction.html

Network Availability
If your daemon depends on the network being available, this cannot be handled with dependencies because network interfaces can come and go at any time in OS X. To solve this problem, you should use the network reachability functionality or the dynamic store functionality in the System Configuration framework. This is documented in System Configuration Programming Guidelines and System Configuration Framework Reference. For more information about network reachability, see Determining Reachability and Getting Connected in System Configuration Programming Guidelines.