No description or website provided.
Latest commit 42f4b26 Jul 9, 2016 @cgsmith cgsmith committed on GitHub Merge pull request #116 from ejfrancis/patch-1
fix readme doc for remove_on_demand


Gem Version Gem Gem

Gitter Twitter

This plugin adds an entry to your /etc/hosts file on the host system.

On up, resume and reload commands, it tries to add the information, if it does not already exist in your hosts file. If it needs to be added, you will be asked for an administrator password, since it uses sudo to edit the file.

On halt, destroy, and suspend, those entries will be removed again. By setting the config.hostsupdater.remove_on_suspend = false, suspend and halt will not remove them.


$ vagrant plugin install vagrant-hostsupdater

Uninstall it with:

$ vagrant plugin uninstall vagrant-hostsupdater

Update the plugin with:

$ vagrant plugin update vagrant-hostsupdater


You currently only need the hostname and a :private_network network with a fixed IP address. :private_network, ip: ""
config.vm.hostname = ""
config.hostsupdater.aliases = ["", ""]

This IP address and the hostname will be used for the entry in the /etc/hosts file.

Skipping hostupdater

To skip adding some entries to the /etc/hosts file add hostsupdater: "skip" option to network configuration: "private_network", ip: "", hostsupdater: "skip"

Example: :private_network, ip: "" :private_network,
    ip: "",
    netmask: "",
    hostsupdater: "skip"

Keeping Host Entries After Suspend/Halt

To keep your /etc/hosts file unchanged simply add the line below to your VagrantFile:

config.hostsupdater.remove_on_suspend = false

This disables vagrant-hostsupdater from running on suspend and halt.

Passwordless sudo

Add the following snippet to the top of the sudoers file using sudo visudo. It will make vagrant stop asking password when updating hosts file:

# Allow passwordless startup of Vagrant with vagrant-hostsupdater.
Cmnd_Alias VAGRANT_HOSTS_ADD = /bin/sh -c echo "*" >> /etc/hosts
Cmnd_Alias VAGRANT_HOSTS_REMOVE = /usr/bin/env sed -i -e /*/ d /etc/hosts

Note: If vagrant still asks for a password on commands that trigger the VAGRANT_HOSTS_REMOVE alias above (like halt or suspend), this might indicate that the location of sed in the VAGRANT_HOSTS_REMOVE alias is pointing to the wrong location. The solution is to find the location of sed (ex. which sed) and replace that location in the VAGRANT_HOSTS_REMOVE alias. For example, on some newer Ubuntu versions (seen as early as Ubuntu 14.04 with 4.2.0-30-generic kernel - thanks to austinprey), the command portion of that line should change from /usr/bin/sed to /bin/sed like this:

Cmnd_Alias VAGRANT_HOSTS_REMOVE = /bin/sed -i -e /*/ d /etc/hosts

Installing development version

If you would like to install vagrant-hostsupdater on the development version perform the following:

git clone
cd vagrant-hostsupdater
git checkout develop
gem build vagrant-hostsupdater.gemspec
vagrant plugin install vagrant-hostsupdater-*.gem


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request on the develop branch



  • Feature: Added remove_on_suspend for vagrant_halt #71
  • Feature: Skip entries if they already exist #69
  • Bugfix: Fixing extra lines in /etc/hosts file #87
  • Misc: Fix yellow text on UI #39


  • Bugfix: Fixing up issue on initialize #28


  • Stable release
  • Feature: Added skip flag #69
  • Feature: Hosts update on provision action #65
  • Bugfix: remove_on_suspend should be true #19
  • Bugfix: Line break not inserted before first host #37
  • Bugfix: Old changes not removed in linux #67
  • Bugfix: Writable issue on OSX #47
  • Bugfix: Update hosts before provisioning #31
  • Misc: Using Semantic Versioning for version number
  • Misc: Added note regarding sudoers file


  • bugfix: Fix additional new lines being added to hosts file (Thanks to vincentmac)


  • bugfix: wrong path on Windows systems (Thanks to Im0rtality)


  • bugfix: now not trying to remove anything if no machine id is given


  • trying to use proper windows hosts file


  • using hashed uids now to identify hosts entries (you might need to remove previous hostentries manually)
  • fixed removing of host entries


  • no sudo, if /etc/hosts is writeable


  • option added to not remove hosts on suspend, adding hosts on resume (Thanks to Svelix)


  • fixed problem with removing hosts entries on destroy command (Thanks to Andy Bohne)


  • added aliases config option to define additional hostnames