8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | 23c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Articles » Misc » Here

Dnsmasq : For Simple DNS Configurations on Mac OS X

Dnsmasq is a simple way to set up a DNS server for a small network, rather than going to the trouble of configuring BIND.

Related articles.

Install Homebrew

The easiest way to install Dnsmasq is to use the Homebrew package manager, so we need to install that first. Luckily, this is done using a single command.

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir /usr/local
Password:
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local
==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
==> Downloading and installing Homebrew...
remote: Counting objects: 222406, done.
remote: Compressing objects: 100% (58530/58530), done.
remote: Total 222406 (delta 162645), reused 222391 (delta 162634)
Receiving objects: 100% (222406/222406), 50.38 MiB | 1021.00 KiB/s, done.
Resolving deltas: 100% (162645/162645), done.
From https://github.com/Homebrew/homebrew
 * [new branch]      master     -> origin/master
HEAD is now at b2b1ad2 utils: tweak install_gem_setup_path to not warn.
==> Installation successful!
==> Next steps
Run `brew doctor` before you install anything
Run `brew help` to get started
$

Install Dnsmasq

Dnsmasq can now be installed using the following command.

$ bbrew install dnsmasq
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/dnsmasq-2.72.yosemite.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring dnsmasq-2.72.yosemite.bottle.1.tar.gz
==> Caveats
To configure dnsmasq, copy the example configuration to /usr/local/etc/dnsmasq.conf
and edit to taste.

  cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf

To have launchd start dnsmasq at startup:
    sudo cp -fv /usr/local/opt/dnsmasq/*.plist /Library/LaunchDaemons
    sudo chown root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
Then to load dnsmasq now:
    sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
==> Summary
   /usr/local/Cellar/dnsmasq/2.72: 7 files, 496K
$

As the instructions suggest, do the following.

$ mkdir -p /usr/local/etc/
$ cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf

Setup Dnsmasq to auto start on reboot.

$ sudo cp -fv /usr/local/opt/dnsmasq/*.plist /Library/LaunchDaemons
$ sudo chown root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist

Start Dnsmasq now and accept the warning.

$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist

Stop/Start Dnsmasq

The following commands show how to stop and start Dnsmasq. This must be done after any configuration changes are made.

$ sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist

Configuration

You don't need to do any specific DNS configuration as Dnsmasq will use the contents of the "/etc/hosts" to resolve any name requests. Anything it can't find there will be forwarded to the nameservers listed in the "/etc/resolv.conf" file.

For example, adding the following entries to the "/etc/hosts" file on the Mac running Dnsmasq, will allow it to act as a DNS, resolving those names for any machines on the network, or VMs running on the Mac.

# Oracle Linux 6 - RAC Installation
192.168.0.111   ol6-112-rac1.localdomain            ol6-112-rac1
192.168.0.112   ol6-112-rac2.localdomain            ol6-112-rac2
192.168.1.111   ol6-112-rac1-priv.localdomain       ol6-112-rac1-priv
192.168.1.112   ol6-112-rac2-priv.localdomain       ol6-112-rac2-priv
192.168.0.113   ol6-112-rac1-vip.localdomain        ol6-112-rac1-vip
192.168.0.114   ol6-112-rac2-vip.localdomain        ol6-112-rac2-vip
192.168.0.115   ol6-112-scan.localdomain            ol6-112-scan
192.168.0.116   ol6-112-scan.localdomain            ol6-112-scan
192.168.0.117   ol6-112-scan.localdomain            ol6-112-scan

Any machines in the network that need to use this DNS server for name resolution need their "/etc/resolv.conf" file amended so the "nameserver" entry points at this server.

search localdomain
nameserver 192.168.0.4

Edit the "/usr/local/etc/dnsmasq.conf" file to prevent local network queries being forwarded. My internal domain is called "localdomain", so I add the following setting, then restart Dnsmasq.

local=/localdomain/

For more information see:

Hope this helps. Regards Tim...

Back to the Top.