2
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!
Thanks for your help. I'm not sure I understand what you mean by "Unless, of course, it isn’t actually meant for the dnsmasq host at all, but the WiFi clients or whatever." I am sure that what I want to do is possible because I've done it before. Unfortunately I no longer have access to that device though. The behavior appears to be related to
dnsmasq
because when it is running my/etc/resolv.conf
is set tonameserver 127.0.0.1
byresolvconf
and when it isn't running that line readsnameserver 192.168.1.254
. Shouldn't dnsmasq know which interface the request comes from? – owise1 – 2015-06-09T21:24:06.523Sure it knows where the request comes from. It’s just that it always comes from
lo
when usingnameserver 127.0.0.1
. – Daniel B – 2015-06-10T05:52:57.3471What you want is to avoid whatever is setting your nameserver to 127.0.0.1 in resolvconf. It may be dnsmasq doing it by default unless you use the option not to. – qasdfdsaq – 2015-06-11T16:32:36.727