blob: 1b24e0f6a88c2bee5e9752bc7a48b6793c0b957b (
plain)
1
2
3
4
5
6
7
8
9
10
11
|
<h1 id="basic-usage-of-networking"> Basic Usage of Networking </h1> <p>Vagrant offers multiple options for how you are able to connect your guest machines to the network, but there is a standard usage pattern as well as some points common to all network configurations that are important to know.</p> <h2 id="configuration"> Configuration </h2> <p>All networks are configured within your <a href="../vagrantfile/index">Vagrantfile</a> using the <code>config.vm.network</code> method call. For example, the Vagrantfile below defines some port forwarding:</p> <div class="highlight"><pre class="highlight ruby" data-language="ruby">Vagrant.configure("2") do |config|
# ...
config.vm.network "forwarded_port", guest: 80, host: 8080
end
</pre></div>
<p>Every network type has an identifier such as <code>"forwarded_port"</code> in the above example. Following this is a set of configuration arguments that can differ for each network type. In the case of forwarded ports, two numeric arguments are expected: the port on the guest followed by the port on the host that the guest port can be accessed by.</p> <h2 id="multiple-networks"> Multiple Networks </h2> <p>Multiple networks can be defined by having multiple <code>config.vm.network</code> calls within the Vagrantfile. The exact meaning of this can differ for each <a href="../providers/index">provider</a>, but in general the order specifies the order in which the networks are enabled.</p> <h2 id="enabling-networks"> Enabling Networks </h2> <p>Networks are automatically configured and enabled after they've been defined in the Vagrantfile as part of the <code>vagrant up</code> or <code>vagrant reload</code> process.</p><div class="_attribution">
<p class="_attribution-p">
© 2010–2018 Mitchell Hashimoto<br>Licensed under the MPL 2.0 License.<br>
<a href="https://www.vagrantup.com/docs/networking/basic_usage.html" class="_attribution-link">https://www.vagrantup.com/docs/networking/basic_usage.html</a>
</p>
</div>
|