You've not said which version of MacOS you're on; my reply here is from macOS Sierra Version 10.12.5. (I'm using it in order to run tests against a VMWare installation of ADCS...)
First, the commands to stop and start dnsmasq are:
sudo launchctl stop homebrew.mxcl.dnsmasq
sudo launchctl start homebrew.mxcl.dnsmasq
launchctl stop doesn't actually stop it, it's likely that the
/Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist contains the lines
If you don't want it to be always on, change that to
instead. Or you can disable it with
sudo launchctl disable homebrew.mxcl.dnsmasq
The next time you want to turn it on, run
sudo launchctl enable homebrew.mxcl.dnsmasq
Second, you should check the other values of your dnsmasq.conf file. Here's mine:
[jenny@temeraire ~] $ grep -v ^# /usr/local/etc/dnsmasq.conf | grep -v ^$
Note the line
resolv-file. It tells dnsmasq which nameservers to use for hosts that aren't in the dnsmasq config. In my case, it looks like this:
[jenny@temeraire ~] $ more /usr/local/etc/resolv.conf
So all DNS lookups that aren't answered by my virtual AD server will be handled by Google's nameservers, meaning that I can still connect to hosts that aren't in my config.
Third, to debug whether dnsmasq acts properly, don't use ping. Instead, use dig, like so:
dig @127.0.0.1 abc.test
To test whether your system is using dnsmasq as its resolver, again use dig:
It will tell you what nameserver it's using, among other things.
Dig will give you information about how the lookup is actually done.
Fourth, in order to use dnsmasq as your resolver, you need to also change
/etc/resolv.conf to point to 127.0.0.1 instead of whatever it now points at. You should start by copying your current
/usr/local/etc/resolv.conf, so that dnsmasq will know what nameservers to use. Then change /etc/resolv.conf to read
On my laptop, I do this in System Preferences -> Network -> DNS. I'm not sure how you do it on a server; perhaps simply editing the file will work.