Having an Ubuntu 16.04 testserver without GUI, I want to make ports from Vagrant machines accessable to the host from outside, so that I can access them on my Ubuntu dev VM like this:
[Dev-VM] <---> [Testserver] <---> [Vagrant-Machine]
For this purpose, I added a port forwarding for port 80. This works well with curl from the Testserver, but not from the Dev-VM. Found host_ip
in the docs and tried this:
config.vm.network "forwarded_port", guest: 80, host: 80, host_ip: "0.0.0.0"
Also tried
config.vm.network "public_network"
but same result: I can access the test webserver in the Vagrant-Machine and on the Testserver with curl, but not from my Dev-VM. In my understanding, the host_ip: "0.0.0.0"
should bind port 80 from the VM to any interface on the host, so it should be accessable from other machines in the same network.
First off, I would like to warn you to be very careful with the "public network" config because Vagrant boxes are insecure by default, featuring public passwords, insecure keypairs for SSH access, and potentially allow root access over SSH.
It is a little unclear to me what you are attempting to do. If I have understood correctly, you would like to access your Vagrant-Machine from your Dev-VM and that these are on the same network .
Here is a link to the documentation for private networks: https://www.vagrantup.com/docs/networking/private_network.html#dhcp .
The easiest would be to allow DHCP to give you an available IP adress like such
config.vm.network "private_network", type: "dhcp"
You can determine the given ip by running vagrant ssh
and then running ifconfig
Hope this helps, best regards
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.