I have dnsmasq running on a raspberry pi w/Raspbian. The pi has a wifi stick on wlan0 and is connected to the local network/internet on eth0. My goal is to have dnsmasq resolve all hosts to the pi's static IP only for wifi connections. This is my dnsmasq.conf
address=/#/192.168.42.1
interface=wlan0
Now however, when I ssh to the pi through eth0 and ping google.com it resolves to 192.168.42.1 also. Perhaps that's because of this (from the man page):
Dnsmasq automatically adds the loopback (local) interface to the list of interfaces to use when the --interface option is used
If so, how can I make it so that dnsmasq only listens to the wifi connections?
Workaround Solution
For my purposes it was ok for the logic to be: "If an ethernet cable is plugged in, turn off dnsmasq
. If an ethernet cable is unplugged, turn it back on".
Therefore, I used ifplugd
to manage the process. In the file /etc/ifplugd/ifplud.action
I added service dnsmasq stop
to the "up" case and service dnsmasq start
to the "down" case. Full success!