Information Technology Reference
In-Depth Information
config.vm.network :forwarded_port, guest: N, host: M
sets the forwarding in such a way that a connection to your host machine on port num-
ber M will be served by daemon on the port N working on the guest system. The in-
formation about forwarding is printed when your system boots:
[default] Forwarding ports...
[default] -- N => M (adapter 1)
If you want to serve web pages by apache running on the guest machine you can use
the following settings:
config.vm.network :forwarded_port, guest: 80, host: 8080
With the above settings the addresses http://localhost:8080 you used in
your host operating system will be served by daemon running on port 80 of the guest
operating system. If your machine is available as example.net, then everyone can use
http://example.net:8080 . The requests will be forwarded to your guest dae-
mon running port 80. The information about forwarding 8080 on host to 80 on guest is
presented during booting in this way:
[default] Forwarding ports...
[default] -- 80 => 8080 (adapter 1)
By default, Vagrant uses the following rule:
config.vm.network :forwarded_port, guest: 22, host: 2222
presented as:
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
That's why you can connect to the guest operating system with $ vagrant ssh
or standard ssh clients. When you boot the virtual system, the port 2222 is forwarded to
ssh daemon running on the guest operating system on the standard port 22. The con-
nections to port 22 on the guest operating system are by default restricted to the IP ad-
dress 127.0.0.1. That's why if you want to use ssh to your guest operations system
through the network you have to use the following configuration settings:
Search WWH ::




Custom Search