Chapter 4. Networking in Vagrant
Part of the ideal Vagrant workflow is the firm belief that you should be able to continue using existing browsers and development tools on your local machine.
One example of this is shared folders, which you saw briefly when setting up your first Vagrant environment. Shared folders allow you to work on your own machine and have files synced into the guest machine, letting you continue to use your own editor.
Likewise, to use your own browser for web applications, we need a way to expose network applications such as web servers to the outside world from the virtual machine. To do this, Vagrant exposes a set of options for networking the virtual machine.
Vagrant offers three networking options to maximize flexibility: forwarded ports, host-only networking, and bridged networking.
Each networking option has its own specific use case and set of upsides and downsides. Understanding each of these is important to getting the most value possible from Vagrant.
For this chapter, we’ll continue building on the previous virtual machine configured to install Apache. If you haven’t done this yet, spend some time quickly setting up your Vagrantfile with the shell configuration to install Apache. If you’re using Chef or Puppet, that is fine, as long as it is provisioned following the examples in Chapter 3.
Using this virtual machine running Apache, we’ll review each option of networking in order to see how it works, and the benefits and costs associated with each.
Forwarded ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access