vagrant-dnsmasq Build Status

A Dnsmasq Vagrant plugin that manages the dnsmasq.conf file and /etc/resolver directory on your host system.

Prerequisites

Easily install dnsmasq with brew under Mac OS: brew install dnsmasq

Installation

vagrant plugin install vagrant-dnsmasq

Usage

in your Vagrantfile

# set domain ending (required)
# adding this line enables dnsmasq handling
config.dnsmasq.domain = '.dev'


# optional configuration ...

# this plugin runs 'hostname -I' on the guest machine to obtain
# the guest ip address. you can overwrite this behaviour.
# config.dnsmasq.ip = '192.168.59.100'

# config.dnsmasq.ip = proc do |guest_machine| 
#   guest_machine.communicate.sudo("command to obtain ip somehow") do |type, data| 
#     # return something like '192.168.59.100' or ['192.168.59.100', '192.168.59.103']
#   end
# end

# this will prompt you during 'vagrant up' to choose an IP
# config.dnsmasq.ip = ['192.168.59.100', '192.168.59.103']

# overwrite default location for /etc/resolver directory
# config.dnsmasq.resolver = '/etc/resolver'

# 'vagrant destroy' does not delete /etc/resolver nameserver file, defaults to false
# config.dnsmasq.keep_resolver_on_destroy = true

# overwrite default location for /etc/dnsmasq.conf
brew_prefix = `brew --prefix`.strip
config.dnsmasq.dnsmasqconf = brew_prefix + '/etc/dnsmasq.conf'

# disable dnsmasq handling
# config.dnsmasq.disable = true

Uninstall

vagrant plugin uninstall vagrant-dnsmasq

Verify /etc/resolver and $(brew --prefix)/etc/dnsmasq.conf.

Alternatives

/etc/resolver approach

/etc/hosts approach