Information Technology Reference
In-Depth Information
concerns port forwarding.
Port forwarding
As you already know, when you boot the virtual machine your computer runs two oper-
ating systems: the host operating system and the guest operating system. I will assume
that your host operating system is Windows and your guest operating system is Ubuntu
12.04. While the following explanation is true whatever your operating systems are
these assumptions will help me clarify matters.
The main point you have to understand is that each of these systems uses its own
TCP ports .
Let's suppose that you work on Windows (i.e., host OS). You start the web browser
and you type the address http://localhost:8080 . The browser will try to con-
nect to the port 8080 on your host operating system (i.e., Windows). If you run the
apache server on your Windows machine using the 8080 port, the connection can be
successful. Your browser receives a web page served by your host machine.
Let's consider the guest operating system Ubuntu. Suppose that you open the ssh
connection to your virtual machine and within your ssh session you run:
# Guest OS (Ubuntu 12.04)
$ ftp localhost:8080
The ftp will try to open the TCP connection to port 8080 on your guest operating
system Ubuntu 12.04. If Ubuntu runs ftp daemon using the 8080 port, your ftp client
will receive some ftp output.
In both cases the same port number 8080 was used. But as you can see the same port
number can be assigned to different TCP/IP services. If your client runs on the host
machine you will connect to the daemon on the host machine. If your client runs on the
guest machine you will connect to the daemon on the guest machine.
We can say that both systems are separated.
From the outside world your guest operating system is not accessible at all. If your
IP address is 192.168.10.225 and someone on your network tries to access ht-
tp://192.168.10.225:8080 , then his request will be sent to the host operating
system (i.e., Windows).
How can we connect ports on the host and guest operating systems? This can be
done with the config.vm.network configuration option in Vagrantfile. The op-
tion:
Search WWH ::




Custom Search