
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
Manage vagrant guest local DNS resolution.
The vagrant-hosts plugin provides a hosts provisioner which assembles hosts file content based on explicit information and private_network settings. Dynamic sources of hostname info, such as DHCP or provider-specific SSH info are currently not considered.
These settings are on a per provisioner basis. They configure the individual behaviors of each provisioner instance.
hosts
[]exports
[address, [aliases]]
entries that are exported by this VM. These exports can be collected
by other VMs using the imports setting. These entries may use special
keys as described in the next section.{}imports
[]autoconfigure
true if hosts is empty, otherwise false.add_localhost_hostnames
127.0.1.1truechange_hostname
truesync_hosts
falseThe tuples used by the hosts and exports settings are of the form:
[address, [aliases]]
For each component, there are some special keys defined that will be replaced by data determined from the VM.
For address, the following special keys may be used:
@facter_ipaddress: Expands to the IPv4 address assigned to the
default network interface of the guest VM.
@vagrant_private_networks: Expands to create one host entry with the given
aliases for each private network attached to a VM that has an explicitly
configured ip address. This is similar to the autoconfigure setting, but
gives control over which aliases are used.
@vagrant_ssh: Expands to the IP address that vagrant ssh uses to connect
with the VM.
For aliases, the following special keys may be used:
@vagrant_hostnames: Expands to an array of aliases containing:
Manually specify addresses:
Vagrant.configure('2') do |config|
config.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
config.vm.provision :hosts do |provisioner|
# Add a single hostname
provisioner.add_host '10.0.2.2', ['myhost.vagrantup.internal']
# Or a fqdn and a short hostname
provisioner.add_host '10.0.2.3', ['myotherhost.vagrantup.internal', 'myotherhost']
# Or as many aliases as you like!
provisioner.add_host '10.0.2.5', [
'mypuppetmaster.vagrantup.internal',
'puppet.vagrantup.internal',
'mypuppetmaster',
'puppet'
]
end
end
Autodetect internal network addresses and autoconfigure hosts:
# Autoconfigure hosts. This will copy the private network addresses from
# each VM and update hosts entries on all other machines. No further
# configuration is needed.
Vagrant.configure('2') do |config|
config.vm.define :first do |node|
node.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
node.vm.network :private_network, :ip => '10.20.1.2'
node.vm.provision :hosts, :sync_hosts => true
end
config.vm.define :second do |node|
node.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
node.vm.network :private_network, :ip => '10.20.1.3'
node.vm.provision :hosts, :sync_hosts => true
end
end
Use autodetection with manual entries
Vagrant.configure('2') do |config|
config.vm.define :first do |node|
node.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
node.vm.network :private_network, :ip => '10.20.1.2'
node.vm.provision :hosts do |provisioner|
provisioner.autoconfigure = true
provisioner.sync_hosts = true
provisioner.add_host '172.16.3.10', ['yum.mirror.local']
end
end
config.vm.define :second do |node|
node.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
node.vm.network :private_network, :ip => '10.20.1.3'
node.vm.provision :hosts do |provisioner|
provisioner.autoconfigure = true
provisioner.sync_hosts = true
provisioner.add_host '172.16.3.11', ['apt.mirror.local']
end
end
end
Use exports and special keys to share names among VMs:
Vagrant.configure('2') do |config|
# A node running in a remote compute environment, such as AWS or OpenStack.
config.vm.define :cloud do |node|
node.vm.provision :hosts do |provisioner|
provisioner.sync_hosts = true
provisioner.exports = {
'global' => [
['@vagrant_ssh', ['@vagrant_hostnames']],
],
}
end
end
# A node running locally under Virtualbox
config.vm.define :local do |node|
node.vm.provision :hosts do |provisioner|
provisioner.sync_hosts = true
provisioner.imports = ['global', 'virtualbox']
provisioner.exports = {
'virtualbox' => [
['@vagrant_private_networks', ['@vagrant_hostnames']],
],
}
end
end
end
The vagrant-hosts plugin provides two Vagrant commands:
vagrant hosts list: List private_network host info in /etc/hosts formatvagrant hosts puppetize: List private_network host info as Puppet Host resourcesAs of version 1.0.0 or later Vagrant 1.1 is required.
Supported guests:
vagrant plugin install vagrant-hosts
FAQs
Unknown package
We found that vagrant-hosts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.