Created
May 31, 2010 02:21
-
-
Save mitchellh/419479 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This shows host only networking in a Multi-VM environment. | |
# | |
# The key point in this example is that the web and db sub-VMs | |
# are put on the same network so they can communicate with each | |
# other. | |
Vagrant::Config.run do |config| | |
# ... | |
config.vm.define :web do |web_config| | |
# Attach the web VM to the host only interface with a | |
# static IP. | |
config.vm.network("my_network", "192.168.48.101") | |
# Still forward the port for localhost access on the | |
# host machine (this isn't necessary since you can also | |
# access via the above IP). This will forward the port | |
# on adapter 0 (eth0), whereas the above is setup on | |
# adapter 1 (eth1) | |
config.vm.forward_port("web", 80, 8080) | |
end | |
config.vm.define :db do |db_config| | |
# Attach the DB VM to the same host only network as the | |
# web server so they can talk to each other. | |
config.vm.network("my_network", "192.168.48.102") | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This example represents single VM host only networking. | |
# This is useful in the case where someone wants to add a | |
# single VM to a pre-existing host only networking, and also | |
# provides a solid base to build up for multi-VM. | |
Vagrant::Config.run do |config| | |
# ... | |
# Add to a host only interface. This uses DHCP to get the IP, | |
# and attaches the host only interface to adapter 1 (eth1), by | |
# default. | |
config.vm.network("vboxnet0") | |
# Another example. This is still DHCP but instead attaches to | |
# adapter 2 (eth2). | |
config.vm.network("vboxnet0", :adapter => 2) | |
# Another example. This assigns a static IP to the VM while still | |
# connecting to a host only interface. | |
config.vm.network("vboxnet0", "192.168.48.101") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment