Giter Club home page Giter Club logo

vagrant-dnsmasq's Introduction

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'

# command for reloading dnsmasq after config changes
config.dnsmasq.reload_command = 'sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist; sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist'

# 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

vagrant-dnsmasq's People

Contributors

mattes avatar ryan0x44 avatar stephencroberts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

vagrant-dnsmasq's Issues

Updating an existing domain with new ip

If you change the IP address of a vm that's already been provisioned, the plugin says that it updated the ip address, but the entry in dnsmasq.conf doesn't change, so the domain no longer resolves.

Steps to reproduce:

  • vagrant up
  • Change the IP in Vagrantfile
  • vagrant halt and vagrant up

The VM is no longer accessible with the dnsmasq domain

ffi-1.9.5 not bundled with Vagrant 1.6.5?

Immediately after vagrant plugin install vagrant-dnsmasq, I get the following error upon issuing any vagrant command:

$ vagrant up
/Applications/Vagrant/embedded/gems/gems/bundler-1.6.6/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find ffi-1.9.5 in any of the sources (Bundler::GemNotFound)
    from /Applications/Vagrant/embedded/gems/gems/bundler-1.6.6/lib/bundler/spec_set.rb:85:in `map!'
    from /Applications/Vagrant/embedded/gems/gems/bundler-1.6.6/lib/bundler/spec_set.rb:85:in `materialize'
    from /Applications/Vagrant/embedded/gems/gems/bundler-1.6.6/lib/bundler/definition.rb:133:in `specs'
    from /Applications/Vagrant/embedded/gems/gems/bundler-1.6.6/lib/bundler/definition.rb:178:in `specs_for'
    from /Applications/Vagrant/embedded/gems/gems/bundler-1.6.6/lib/bundler/definition.rb:167:in `requested_specs'
    from /Applications/Vagrant/embedded/gems/gems/bundler-1.6.6/lib/bundler/environment.rb:18:in `requested_specs'
    from /Applications/Vagrant/embedded/gems/gems/bundler-1.6.6/lib/bundler/runtime.rb:13:in `setup'
    from /Applications/Vagrant/embedded/gems/gems/bundler-1.6.6/lib/bundler.rb:120:in `setup'
    from /Applications/Vagrant/embedded/gems/gems/bundler-1.6.6/lib/bundler/setup.rb:17:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'

Vagrant destroy

I'm testing this plugin out and I'm new to ruby world. I had some issues in the beginning to getting it to work with gem errors and finally got it up and running somehow. Now when I delete a VM i get this error. For some reason it thinks the VM is not created. When I ssh back into it the VM has been deleted though.

sudo vagrant destroy
==> default: VM not created. Moving on...
/Users/ezjacob/.vagrant.d/gems/gems/vagrant-dnsmasq-0.0.9/lib/vagrant-dnsmasq/includes/DnsmasqConf.class.rb:51:in delete': invalid domain instance (ArgumentError) from /Users/ezjacob/.vagrant.d/gems/gems/vagrant-dnsmasq-0.0.9/lib/vagrant-dnsmasq/actions.rb:83:incall'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/warden.rb:95:inblock in finalize_action'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/warden.rb:34:incall'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/plugins/providers/virtualbox/action/message_not_created.rb:11:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/warden.rb:34:incall'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/warden.rb:95:in block in finalize_action' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/warden.rb:34:incall'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/builder.rb:116:incall'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/runner.rb:66:in block in run' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/util/busy.rb:19:inbusy'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/runner.rb:66:in run' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/builtin/call.rb:53:incall'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/plugins/providers/virtualbox/action/check_virtualbox.rb:17:incall'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/warden.rb:34:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/builder.rb:116:incall'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/runner.rb:66:in block in run' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/util/busy.rb:19:inbusy'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/action/runner.rb:66:in run' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/machine.rb:196:inaction_raw'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/machine.rb:173:in block in action' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/environment.rb:434:inlock'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/machine.rb:161:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/machine.rb:161:inaction'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/plugins/commands/destroy/command.rb:31:in block in execute' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/plugin/v2/command.rb:226:inblock in with_target_vms'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/plugin/v2/command.rb:220:in each' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/plugin/v2/command.rb:220:inwith_target_vms'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/plugins/commands/destroy/command.rb:30:in execute' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/cli.rb:42:inexecute'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/environment.rb:252:in cli' from /Applications/Vagrant/bin/../embedded/gems/gems/vagrant-1.6.3/bin/vagrant:166:in

'

config correct, nameserver lookup fails though

on Mac OS X:

Even dscacheutil -flushcache and sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist; sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist won't help to do a correct nameserver lookup.

Deactivating the complete network (e.g. Wifi) and re-activating helps though.

How to fix this?

Not all hostname commands support -I

By default this plugin uses 'hostname -I' to try to determine the IP address(es) of a guest system. Unfortunately, not all OS versions support -I. Wouldn't it be just as easy to look at the output of ifconfig and parse it out? Even nicer would be to have it look at ifconfig output and allow you to configure acceptable IP ranges. That way you could filter out localhost, etc.

New release?

Would it be possible to create a new release with all of the latest commits? There are some nice changes in the last year that would be great to have without having to build from source.

vagrant up aborted after installing this plugin

I installed this plugin and vagrant up, it won't proceed with the following error:

โžœ  Projects  vagrant up
/opt/vagrant/embedded/gems/gems/bundler-1.10.5/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find little-plugger-1.1.4 in any of the sources (Bundler::GemNotFound)
    from /opt/vagrant/embedded/gems/gems/bundler-1.10.5/lib/bundler/spec_set.rb:85:in `map!'
    from /opt/vagrant/embedded/gems/gems/bundler-1.10.5/lib/bundler/spec_set.rb:85:in `materialize'
    from /opt/vagrant/embedded/gems/gems/bundler-1.10.5/lib/bundler/definition.rb:140:in `specs'
    from /opt/vagrant/embedded/gems/gems/bundler-1.10.5/lib/bundler/definition.rb:185:in `specs_for'
    from /opt/vagrant/embedded/gems/gems/bundler-1.10.5/lib/bundler/definition.rb:174:in `requested_specs'
    from /opt/vagrant/embedded/gems/gems/bundler-1.10.5/lib/bundler/environment.rb:18:in `requested_specs'
    from /opt/vagrant/embedded/gems/gems/bundler-1.10.5/lib/bundler/runtime.rb:13:in `setup'
    from /opt/vagrant/embedded/gems/gems/bundler-1.10.5/lib/bundler.rb:127:in `setup'
    from /opt/vagrant/embedded/gems/gems/bundler-1.10.5/lib/bundler/setup.rb:18:in `<top (required)>'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
Bringing machine 'default' up with 'virtualbox' provider...
There are errors in the configuration of this machine. Please fix
the following errors and try again:

Dnsmasq configuration:
* file '/etc/dnsmasq.conf' does not exist

Any ideas please?

FYI, my Vagrantfile as follows:

Vagrant.configure(2) do |config|

  config.vm.box = "ubuntu/trusty64"

  username = `whoami`.strip

  config.dnsmasq.domain = '.' + username + '.dev'

  brew_prefix = `brew --prefix`.strip
  config.dnsmasq.dnsmasqconf = brew_prefix + '/etc/dnsmasq.conf'

  config.dnsmasq.reload_command = 'sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist; sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist'

  config.vm.network "forwarded_port", guest: 80, host: 8080

  config.vm.provision :shell, path: "bootstrap.sh"

  config.vm.provision :shell, path: "vhosts.sh", :args => username
end

Release 0.1.2

There's some commits that fix the ffi dependency resolution messages/errors that are present in 0.1.1 which is the version currently available on rubygems, specifically 2826b91

/opt/vagrant/embedded/gems/gems/bundler-1.7.11/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find ffi-1.9.8 in any of the sources (Bundler::GemNotFound)
        from /opt/vagrant/embedded/gems/gems/bundler-1.7.11/lib/bundler/spec_set.rb:85:in `map!'
        from /opt/vagrant/embedded/gems/gems/bundler-1.7.11/lib/bundler/spec_set.rb:85:in `materialize'
        from /opt/vagrant/embedded/gems/gems/bundler-1.7.11/lib/bundler/definition.rb:132:in `specs'
        from /opt/vagrant/embedded/gems/gems/bundler-1.7.11/lib/bundler/definition.rb:177:in `specs_for'
        from /opt/vagrant/embedded/gems/gems/bundler-1.7.11/lib/bundler/definition.rb:166:in `requested_specs'
        from /opt/vagrant/embedded/gems/gems/bundler-1.7.11/lib/bundler/environment.rb:18:in `requested_specs'
        from /opt/vagrant/embedded/gems/gems/bundler-1.7.11/lib/bundler/runtime.rb:13:in `setup'
        from /opt/vagrant/embedded/gems/gems/bundler-1.7.11/lib/bundler.rb:122:in `setup'
        from /opt/vagrant/embedded/gems/gems/bundler-1.7.11/lib/bundler/setup.rb:17:in `<top (required)>'
        from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'

Custom IP getter

I'm trying to set IP using this in VagrantFile:

config.dnsmasq.ip = proc do |guest_machine| 
     guest_machine.communicate.sudo("hostname -I | awk '{print $NF}'") do |type, data| 
       data
    end
end

But there are not any changes in dnsmasq.conf

What's wrong?

* Unknown configuration section 'dnsmasq'.

I'm having issue getting this working right now. I'm getting the following error.

There are errors in the configuration of this machine. Please fix
the following errors and try again:

Vagrant:
* Unknown configuration section 'dnsmasq'.

In my Vagrantfile I added this to the top to make sure that the plugin is installed.

unless Vagrant.has_plugin?("vagrant-dnsmasq")
  raise 'some-plugin is not installed!'
end

Any thoughts on how to debug this issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.