sitelink1  
sitelink2  
sitelink3 http://1 
extra_vars4 ko 
extra_vars5 http://itbr.tistory.com/13 
extra_vars6 sitelink1 

안녕하세요 Dr Reality 입니다.?

 

아마 이 글을 보시는 분들은 버추얼 박스를 이용해서 웹서버를 만드시는 분들이실 겁니다.
그런데 VMWare 와 달리 Virtual Box 는 포트 포워딩을 지원하지 않지요.
그러나 Virtual Box 는 GUI 상에서만 메뉴를 볼 수 없을 뿐이지 간단한 명령으로 포트 포워딩이 가능 합니다.

 

먼저 버추얼 박스 설명서를 보면서 따라해 보겟습니다.

 

#버추얼 박스 설명서는 시작-모든 프로그램-Oracle VM VirtualBox-User Manual(User) 입니다.

 

제가 설명서를 기반으로 설명해 드리는 이유는 설명서에는 더 많은 정보가 들어가 있기 때문입니다.

 

설명서 82 쪽을 보면 포트 포워딩에 대해 자세히 나와 있습니다.

 

#이 글을 따라하시기 전에 VBoxManage 의 위치에 대해 알고 계셔야 합니다.

2011/01/19 - [VirtualBox/VBoxManage] - 찾느라 애먹은 VBoxManage 위치

 

(다른 과정은 전 글에서 보셧을거라 생각하고 VBoxManage 에 대한 설명은 생략합니다.)

 

포트 포워딩 명령은 설명서에 나오듯이

 

VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"

 

VM name - 버추얼 박스 VM 의 이름
guestssh - 설정 이름 (주로 포트를 사용하는 서버의 이름이 들어간다 예) Apache2, vsftpd, ssh 등)
tcp - 주로 이걸 사용하니 변경 안해도 된다. 그러나 필요할 경우 udp 등으로 변경 해 주어야 한다.

 

#주의 tcp,,2222,,22 입니다!


2222 - 호스트로 들어오는 포트


22 - 게스트로 들어가는 포트
?
이렇게 변경해 주시면 됩니다.
예를 들어

 

VM name - 버추얼 박스 VM 의 이름
    - Windows
guestssh - 설정 이름 (주로 포트를 사용하는 서버의 이름이 들어간다 예) Apache2, vsftpd, ssh 등)
    - apache
tcp - 주로 이걸 사용하니 변경 안해도 된다. 그러나 필요할 경우 udp 등으로 변경 해 주어야 한다.
    - tcp

2222 - 호스트로 들어오는 포트
    - 8080
22 - 게스트로 들어가는 포트
    - 80

이렇게 명령을 주시면 됩니다.

 

VBoxManage modifyvm "Windows" --natpf1 "apache,tcp,,8080,,80"

 

 

 

6.3.1 Configuring port forwarding with NAT
As the virtual machine is connected to a private network internal to VirtualBox and invisible
to the host, network services on the guest are not accessible to the host machine or to other
computers on the same network. However, like a physical router, VirtualBox can make selected
services available to the world outside the guest through port forwarding. This means that
VirtualBox listens to certain ports on the host and resends all packets which arrive there to the
guest, on the same or a different port.
To an application on the host or other physical (or virtual) machines on the network, it looks as
though the service being proxied is actually running on the host. This also means that you cannot
run the same service on the same ports on the host. However, you still gain the advantages of
running the service in a virtual machine . for example, services on the host machine or on other
virtual machines cannot be compromised or crashed by a vulnerability or a bug in the service,
and the service can run in a different operating system than the host system.
You can set up a guest service which you wish to proxy using the command line tool
VBoxManage; for details, please refer to chapter 8.7, VBoxManage modifyvm, page 104.
You will need to know which ports on the guest the service uses and to decide which ports
to use on the host (often but not always you will want to use the same ports on the guest and
on the host). You can use any ports on the host which are not already in use by a service. For
example, to set up incoming NAT connections to an ssh server in the guest, use the following
command:

VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"

With the above example, all TCP traffic arriving on port 2222 on any host interface will be
forwarded to port 22 in the guest. The protocol name tcp is a mandatory attribute defining
which protocol should be used for forwarding (udp could also be used). The name guestssh is
purely descriptive and will be auto-generated if omitted. The number after --natpf denotes the
network card, like in other parts of VBoxManage.
To remove this forwarding rule again, use the following command:

VBoxManage modifyvm "VM name" --natpf1 delete "guestssh"

If for some reason the guest uses a static assigned IP address not leased from the built-in DHCP
server, it is required to specify the guest IP when registering the forwarding rule:
VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,10.0.2.19,22"
This example is identical to the previous one, except that the NAT engine is being told that the
guest can be found at the 10.0.2.19 address.
To forward all incoming traffic from a specific host interface to the guest, specify the IP of that
host interface like this:

VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,127.0.0.1,2222,,22"

This forwards all TCP traffic arriving on the localhost interface (127.0.0.1) via port 2222 to port
22 in the guest.
It is not possible to configure incoming NAT connections while the VM is running. However,
you can change the settings for a VM which is currently saved (or powered off at a snapshot).