Information Technology Reference
In-Depth Information
config.vm.network :forwarded_port, guest: 22, host: 22
The above rule turns on port forwarding: the connections to port 22 on the host ma-
chine will be served by service 22 on the guest machine. The IP addresses are not re-
stricted, thus everyone on the network can use ssh to your virtual machine.
The configuration used in this recipe:
config.vm.network :forwarded_port, guest: 9418, host: 9418
turns on forwarding for port 9418. This is the standard port used by git daemon. All the
requests to your host machine to port 9418 are served by daemon running on the guest
operating system on the same port.
Hint The documentation for git daemon is available as $ git daemon --help
What happens if you boot two virtual machines?
When you boot two virtual machines they both cannot use the same ports. Therefore,
the port 2222 can be forwarded to only one of them. The first virtual machine you boot
will get the port number 2222 for its ssh daemon:
# Booting the first virtual machine
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
The second virtual machine will obtain the 2200 port:
# Booting the second virtual machine
[default] Forwarding ports...
[default] -- 22 => 2200 (adapter 1)
It is very easy to forget which port is used for which machine. Therefore I advise
you to have only one virtual machine running at any given time.
The command:
$ vagrant ssh
Search WWH ::




Custom Search