Skip to content

Instantly share code, notes, and snippets.

@bradleybeddoes
Last active January 3, 2016 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradleybeddoes/8531497 to your computer and use it in GitHub Desktop.
Save bradleybeddoes/8531497 to your computer and use it in GitHub Desktop.
My DNSMasq configuration on OSX

Developing on OSX with DNSMasq

Overview

Allows multiple VirtualBox nodes to operate within a local DNS context and supports failover for DNS servers when moving to a network (QUT in my case) that does not support resolution of DNS through the their firewall.

By default Google public DNS servers are utilised for speed, security and sane results.

Another benefit of this approach is that I no longer need to run a bind instance locally which seems to break between major OSX revisions and was more of a pain to configure.

Installation

brew install dnsmasq 

Setup

Use the following files as an example for setting up the dnsmasq internals.

Configure OSX to resolve against 127.0.0.1 only for DNS requests.

#### ... stuff ...
## DNSMASQ
alias dnsmasqedit='vi /usr/local/etc/dnsmasq.conf'
alias dnsmasqaddserver='vi ~/Development/dev-vm-dns.conf'
alias dnsmasqrestart='sudo launchctl stop homebrew.mxcl.dnsmasq && sudo launchctl start homebrew.mxcl.dnsmasq'
#### ... stuff ...
## /Users/bradleybeddoes/Development/dev-vm-dns.conf
# AAF VM set
### DB Cluster
address=/db1n1.aaf.l.z5.io/192.168.56.2
address=/db1n2.aaf.l.z5.io/192.168.56.3
address=/db1n3.aaf.l.z5.io/192.168.56.4
### Ansible Master
address=/master.aaf.l.z5.io/192.168.56.8
### Discovery
address=/ds.aaf.l.z5.io/192.168.56.5
### Application Hosts
address=/vho.aaf.l.z5.io/192.168.56.6
address=/manager.aaf.l.z5.io/192.168.56.7
address=/ecpvalidator.aaf.l.z5.io/192.168.56.31
## /usr/local/etc/dnsmasq.conf
# Development VM addresses
conf-file=/Users/bradleybeddoes/Development/dev-vm-dns.conf
# Listen on local loopback
listen-address=127.0.0.1
# Listen on Virtualbox Gateway
listen-address=192.168.56.1
# Resolvers for external addresses
resolv-file=/etc/resolv.dnsmasq.conf
## /etc/resolv.dnsmasq.conf
# DNS resolvers we want to use in order of preference
# Failover occurs when servers are uncontactable
# Google
nameserver 8.8.8.8
nameserver 8.8.4.4
# QUT
nameserver 131.181.59.48
# Add other forced DNS servers here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment