Host-Only networking documentation
This commit is contained in:
parent
002a366d9d
commit
c3e1a87bf3
|
@ -14,7 +14,7 @@
|
|||
</li>
|
||||
<li><a href="/docs/boxes.html">Boxes</a></li>
|
||||
<li><a href="/docs/multivm.html">Multi-VM Environments</a></li>
|
||||
<li><a href="/docs/host_only_networking.html">Host Only Networking</a></li>
|
||||
<li><a href="/docs/host_only_networking.html">Host-Only Networking</a></li>
|
||||
<li><a href="/docs/base_boxes.html">Base Boxes</a></li>
|
||||
<li><a href="/docs/systems.html">Systems</a></li>
|
||||
<li><a href="/docs/rake.html">Rake Integration</a></li>
|
||||
|
|
|
@ -14,9 +14,24 @@ VirtualBox version is running and use the correct API calls.
|
|||
|
||||
Vagrant can now automate and manage multiple VMs to represent a single
|
||||
project. This allows developers to model more complex server setups on
|
||||
their development machine.
|
||||
their development machine. A very basic multi-VM Vagrantfile is shown
|
||||
below:
|
||||
|
||||
TODO: More explanation + docs.
|
||||
{% highlight ruby %}
|
||||
Vagrant::Config.run do |config|
|
||||
config.vm.define :web do |web_config|
|
||||
web_config.vm.box = "web"
|
||||
web_config.vm.forward_port("http", 80, 8080)
|
||||
end
|
||||
|
||||
config.vm.define :db do |db_config|
|
||||
db_config.vm.box = "db"
|
||||
db_config.vm.forward_port("db", 3306, 3306)
|
||||
end
|
||||
end
|
||||
{% endhighlight %}
|
||||
|
||||
For more information, please read the page on [multi-VM environments](/docs/multivm.html).
|
||||
|
||||
## Host Only Networking
|
||||
|
||||
|
@ -25,9 +40,15 @@ Vagrant now allows VMs to specify a static IP for themselves, which
|
|||
can be accessed on the host machine or any other VMs on the same
|
||||
host only network. This feature can work hand in hand with the multi-VM
|
||||
feature announced above to provide efficient internal networking between
|
||||
VMs.
|
||||
VMs. An example of assigning a static IP to a VM is shown below:
|
||||
|
||||
TODO: Docs
|
||||
{% highlight ruby %}
|
||||
Vagrant::Config.run do |config|
|
||||
config.vm.network("192.168.10.10")
|
||||
end
|
||||
{% endhighlight %}
|
||||
|
||||
For more information, read the page on [host only networking](/docs/host_only_networking.html).
|
||||
|
||||
## Automatic Port Collision Fixes
|
||||
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
---
|
||||
layout: documentation
|
||||
title: Documentation - Host-Only Networking
|
||||
---
|
||||
# Host-Only Networking
|
||||
|
||||
Host-Only networking is a feature of VirtualBox which allows multiple
|
||||
virtual machines to communicate with each other through a network via
|
||||
the host machine. The network created by host-only networking is private
|
||||
to the VMs involved and the host machine. The outside world cannot
|
||||
join this network.
|
||||
|
||||
Vagrant allows users to assign a static IP to a VM, which is then
|
||||
setup using host-only networking.
|
||||
|
||||
<div class="info">
|
||||
<h3>Debian/Ubuntu Only!</h3>
|
||||
<p>
|
||||
Since setting up host-only networking requires configuring the OS to
|
||||
use the new interface, this is a system behavior. Currently, Vagrant
|
||||
only supports Ubuntu/Debian out of the box.
|
||||
</p>
|
||||
<p>
|
||||
If you'd like another OS supported, you can add it yourself using a
|
||||
<a href="/docs/systems.html">custom system</a> or you can get in touch
|
||||
with a Vagrant developer and assist us in adding it to the core.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
## Assigning an IP
|
||||
|
||||
Assigning an IP to a virtual machine using Vagrant is simple enough,
|
||||
using a single function within the Vagrantfile:
|
||||
|
||||
{% highlight ruby %}
|
||||
Vagrant::Config.run do |config|
|
||||
config.vm.network("192.168.10.10")
|
||||
end
|
||||
{% endhighlight %}
|
||||
|
||||
The above will setup the VM with that specific IP. It is up to the user
|
||||
to make sure that no static IPs will collide with other virtual machines.
|
||||
|
||||
## Multiple Networks
|
||||
|
||||
By default, Vagrant uses a netmask of `255.255.255.0`. This means that
|
||||
as long as the first three parts of the IP are equivalent, VMs will join
|
||||
the same network. So if two VMs are created with IPs `192.168.10.10` and
|
||||
`192.168.10.11`, they will be networked together. However, if a VM is
|
||||
created with an IP of `192.168.11.10`, it will be on a separate network
|
||||
and will not be able to communicate with the other VMs.
|
||||
|
||||
A custom netmask can also be used, although a netmask of `255.255.255.0`
|
||||
should be sufficient in most cases. An example of using a custom netmask
|
||||
is shown below:
|
||||
|
||||
{% highlight ruby %}
|
||||
Vagrant::Config.run do |config|
|
||||
config.vm.network("192.168.11.10", :netmask => "255.255.0.0")
|
||||
end
|
||||
{% endhighlight %}
|
||||
|
|
@ -76,7 +76,7 @@ With multiple VMs up and running, the next step is to support inter-VM
|
|||
communication so that, say, a web server can talk to its associated database
|
||||
server.
|
||||
|
||||
This communication is done through [host only networking](/docs/host_only_networking.html). There is an entire page dedicated to the topic, but a relatively simple
|
||||
This communication is done through [host-only networking](/docs/host_only_networking.html). There is an entire page dedicated to the topic, but a relatively simple
|
||||
example is given below, based on the example given earlier:
|
||||
|
||||
{% highlight ruby %}
|
||||
|
@ -97,7 +97,7 @@ The above assigns a static IP to both the web and database VMs. This
|
|||
static IP can then be used to communicate directly to the other VMs.
|
||||
For more details on how to do things such as creating separate networks,
|
||||
joining the same network from separate Vagrantfiles, etc. please read
|
||||
the [host only networking](/docs/host_only_networking.html) page.
|
||||
the [host-only networking](/docs/host_only_networking.html) page.
|
||||
|
||||
<div class="info">
|
||||
<h3>All ports are open!</h3>
|
||||
|
|
Loading…
Reference in New Issue