Hello, Networking noob here. Nice to meet everyone!
I have created a Vagrantfile where I use a variable that allows me to switch between public or private networking types: https://github.com/mhulse/vagrant-latmp/blob/382ca7463570f751a1f39d258cb4936c7b9640ba/Vagrantfile I am not sure if I fully understand which network type is most optimal to use and when ... - *When would I want to use private over public?* - *Which one would work best (or at all) with forwarded ports?* - *What is the advantage to one over the other?* Here's my current understanding (could some one confirm/deny/correct my assumptions): 1. NAT port forwarding = "private_network" - Connect, from host, using "localhost" - Port forwarding works (why? because localhost is used by host machine and ports could collide?) - Setting "auto_correct" will fix any port collisions between guest and host 2. Public Network (VirtualBox Bridged networking) = "public_network" - You have to connect using IP address of box (DHCP or defined via config.vm.network.ip) - Port forwarding does not work (why? is this because the machine handles this via Apache/Tomcat, etc, and using IP means no sharing by host machine so no ports would collide?) - Setting "auto_correct" is not needed because port forwarding isn't needed (or is ignored by Vagrant when network type is "public"?) So it sounds like, to clarify my thoughts/understanding further: - Use "private_network" (Vagrant default) if you want to use "localhost" and use port forwarding to avoid port collisions between guest VM and host machine. - Use "public_network" if you want to connect to VM using IP address; port forwarding is not required because VM uses it's own IP address so ports will not collide between guest VM and host machine. Does that sound right? One last question: - *If you use "private_network", and provide an IP, do you still have to worry about forwarded ports and collisions (assuming yes)?* Thanks so much for taking the time to read/help. Sorry if noob questions. Just trying to learn and become more aware of how things work. :) -- This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list. GitHub Issues: https://github.com/mitchellh/vagrant/issues IRC: #vagrant on Freenode --- You received this message because you are subscribed to the Google Groups "Vagrant" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/bad66b3d-699a-4637-8e12-040f6335ef4e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
