Adding 127.0.0.1 to /etc/hosts using the vagrant hosts updater?

15 views
Skip to first unread message

Andrew Leer

unread,
Jan 25, 2017, 4:27:48 PM1/25/17
to WordPress and Vagrant
I read here and here that the vagrant hostsupdater plugin is supposed to update the host's /etc/hosts (or just hosts file as the case may be); I have a need to do this with forwarded ports instead of a private network, so, is that possible, or does my end-user (another developer) have to edit the hosts file themselves when setting up the dev environment?


Vagrant.configure("2") do |config| # ... # Forward guest port 80 to host port 8888 and name mapping config.vm.network :forwarded_port, guest: 80, host: 8888 config.vm.network :forwarded_port, guest: 443, host: 8443 # REMEMBER TO ADD THIS TO THE HOST's /etc/hosts as the loopback (127.0.0.1, or [::1]) config.vm.hostname = "dot.org" config.hostsupdater.aliases = ["www.dot.org"] # ... end

At the moment if I add the following manually, I can access the forwarded ports as expected but the hostsupdater plugin
doesn't do it automatically:

127.0.0.1 dot.org # VAGRANT ... 127.0.0.1 www.dot.org # VAGRANT ...

Is it possible to use the hostsupdater plugin or something else to add these lines automatically to /etc/hosts on vagrant up,
and remove them on vagrant destroy?

Thank you,
Andrew J. Leer
Reply all
Reply to author
Forward
0 new messages