Computer >> 컴퓨터 >  >> 소프트웨어 >> 가상 기기

VirtualBox의 네트워크 및 공유 - 전체 자습서

VirtualBox 관리에 대한 네 번째 기사입니다. 오늘은 VirtualBox 네트워킹 및 공유에 대해 알아야 할 모든 것을 알려드리겠습니다.

가상 머신을 구성하는 세 가지 방법과 호스트 머신과 가상 머신 간에 데이터를 공유하는 세 가지 방법을 보여 드리겠습니다. 이 튜토리얼을 마스터하고 나면 VirtualBox를 재미있고 자신 있게 사용하는 방법에 대해 알아야 할 모든 것을 알게 될 것입니다. 나를 따르라.

소개

자세한 내용은 다음 기사를 읽어야 합니다. 그들은 오늘의 자료를 쉽고 즐겁게 따라가는 데 필요한 배경 지식을 제공할 것입니다.

VirtualBox Guest Additions 설치 방법 - 튜토리얼

VirtualBox 3는 놀랍습니다!

VirtualBox 3 Compiz 슬라이드쇼

VirtualBox 3의 DirectX - 순수한 기쁨이 여기 있습니다

마찬가지로 이 시리즈의 처음 세 편을 읽어야 합니다.

VirtualBox에서 디스크를 복제하는 방법 - 자습서

VirtualBox에 하드 디스크를 추가하는 방법 - 튜토리얼

VirtualBox에서 디스크를 확장/축소하는 방법 - 튜토리얼

이제 시작하겠습니다.

VirtualBox 네트워크 옵션

설치된 가상 머신에 대해 설정> 네트워크를 클릭합니다. 여기서 재미가 시작됩니다. 이것이 기본 보기입니다. 모든 가상 머신에는 최대 4개의 네트워크 어댑터가 있을 수 있습니다. 필요에 따라 선택적으로 활성화할 수 있습니다. 대부분의 사람들은 하나만 필요합니다.

어댑터 유형은 VirtualBox가 가상 머신에 노출할 가상화된 하드웨어를 정의합니다. 어댑터 유형 중 하나에 문제가 있는 경우 다른 어댑터 유형을 시도할 수 있습니다. PCnet-FAST III가 기본 선택입니다.

또한 구형 컴퓨터용 PCnet-FAST II와 프로덕션 환경에서 VirtualBox를 실행하는 사람들에게 유용할 두 가지 서버 버전을 포함하여 세 가지 유형의 Intel PRO/1000 카드가 있습니다. 가정 사용자의 경우 선택이 다소 투명합니다.

가장 흥미로운 부분은 Attached to:섹션입니다. 이 범주는 네트워크 어댑터가 기존 물리적 하드웨어와 인터페이스하는 방법을 정의합니다. 설정이 다르면 결과가 현저하게 달라집니다.

네트워크 유형

여기에는 NAT(기본값), 브리지, 내부 네트워크 및 호스트 전용의 네 가지 옵션이 있습니다. 물론 Not Attached도 유형이지만 실제로 사용할 수 있는 유형은 아닙니다.

네트워크 주소 변환(NAT)

NAT는 가상 머신이 외부에서 라우팅할 수 없는 개인 IP 주소를 갖게 됨을 의미합니다.

예:호스트는 192.168.1.1입니다. VirtualBox NAT 장치는 10.0.2.1로 표시됩니다. 따라서 가상 머신에는 10.0.2.x 범위의 모든 주소가 지정됩니다. 10.0.2.x/24 서브넷의 컴퓨터에 대한 액세스를 라우팅할 것이 없기 때문에 호스트에서 액세스할 수 없습니다.

이 설정은 게스트가 각자 고유한 IP 주소를 가지고 있는지 별로 신경쓰지 않을 때 유용합니다. 그러나 전달이 필요하거나 서비스를 외부에 노출해야 하는 경우에는 좋지 않습니다. 마찬가지로 이 설정은 네트워크 액세스를 통한 공유에 적합하지 않습니다.

장점:단순함과 은둔.

단점:가상 머신에 대한 경로가 없고 네트워크 공유가 없습니다.

브리지 어댑터

브리지 어댑터는 실행 중인 모든 가상 머신이 현재 활성화된 기본 네트워크 주소에서 IP 주소를 얻은 동일한 소스에서 IP 주소를 얻으려고 시도함을 의미합니다. 따라서 브리지라는 용어는 둘이 연결되어 있기 때문입니다.

활성 네트워크 장치가 두 개 이상인 경우 VirtualBox와 연결하려는 장치를 선택할 수 있습니다. 이 경우 무선 어댑터 wlan0을 사용합니다.

예:호스트가 라우터에서 192.168.1.100 주소를 임대했습니다. 가상 머신은 라우터에서 192.168.1.103 주소를 임대합니다. 이제 두 시스템이 동일한 네트워크를 공유하고 모든 표준 규칙이 적용됩니다. 모든 실제적인 목적을 위해 가상 머신은 LAN의 또 다른 IP 주소입니다.

더 자세히, 호스트:

그리고 손님:

이 설정은 장치(스위치, 라우터, ISP 등)에서 둘 이상의 IP 주소 임대를 허용하지 않는 경우 작동하지 않습니다. 따라서 인터넷에 직접 액세스할 수 있는 컴퓨터는 브리지 네트워킹을 사용하지 못할 수 있습니다.

장점:포트 포워딩 및 서비스 활성화로 네트워크를 유연하게 관리할 수 있습니다. 고전적인 방식으로 네트워크 공유를 허용합니다.

단점:직접 인터넷 액세스(라우터 필요)로 작동하지 않을 수 있고, 새로운 사용자가 이해하기 더 어렵고, 가능한 보안 영향으로 시스템을 네트워크에 노출시킵니다.

호스트 전용 어댑터

호스트 전용 어댑터는 매우 흥미롭습니다. IP 주소를 임대하기 위해 vboxnet0이라는 전용 네트워크 장치를 사용한다는 점을 제외하면 브리지 어댑터와 매우 유사합니다.

호스트 머신은 IP 주소가 192.168.56.1인 사실상의 VirtualBox 라우터입니다. 호스트 전용 설정으로 실행 중인 가상 머신이 없으면 어댑터가 사용되지 않습니다. 그러나 일단 나타나면 이 어댑터는 가상 머신에 IP 주소를 제공하여 자체 네트워크 내에서 내부 LAN을 생성합니다.

예:호스트의 IP 주소는 192.168.56.1입니다. 가상 머신의 IP 주소는 192.168.56.101입니다.

더 자세히 호스트:

그리고 손님:

이것은 VMware Server가 수행하는 것과 매우 유사합니다. VMware Server에는 vmnet1 및 vmnet8이라는 두 개의 가상 어댑터가 있으며 NAT 및 호스트 전용 IP 주소를 게스트에 할당하는 데 사용됩니다. However, unlike the VirtualBox NAT adapter, VMware Server always bridges the default network device on your hosts and therefore you have direct network access to NAT-ed machines. You don't have this luxury on VirtualBox (yet).

But the addition of vboxnet0 in VirtualBox 3 has significantly simplified network usage in this phenomenal product. If you wish to recall the trouble I've had to deal with in earlier release of VirtualBox, do take a look at my VMGL tutorial. I had to manually configure everything. BTW, you can change the default IP address allocation, if you want. Very importantly, please note that using the Host-only adapter does not mean your guests will have Internet access. In fact, they won't. vboxnet0 does not have a default gateway. To make vboxnet0 also serve queries outside the local network, you will have to configure it to use another adapter for that, enable forwarding and possible reconfigure your firewall rules. At the end, you will have achieved Bridged networking, so why bother?

Host-only Adapter is useful for creating private networks, where machines need access to one another, but not necessarily outside this subnet.

Pluses:Useful for noisy software testing, penetration testing. Allows classic network sharing via IP address.

Minuses:As difficult to understand as Bridged networking for new users, no Internet access in the virtual machines. May introduce a security risk to other machines on the private network.

Internal network

Internal network is not very interesting, in my opinion. It's similar to Host-only + NAT, except the networking takes place inside the virtual network of guest machines, without any access for the host, plus there is no real NAT. What you get is a private LAN for your guests only, without any access to the external world.

Sharing in VirtualBox

Now that we understand networking options, let's try some sharing. There are two ways you can share your data in VirtualBox, either by direct network access, using IP addresses, or by using the Shared Folders feature.

Personally, I prefer the network solution, because this is how things work in the real world. You send requests to other machines via the network. If they have sharing services, like NFS or Samba listening and if you're properly authenticated, you'll be given the list of shares and allowed to exchange files with this server. Another way of sharing is by FTP or SSH, again, using the classic network channels.

Shared Folders is a feature where you create a folder on your host and then mount it inside your virtual machines. It works for all network setups and uses an internal VirtualBox sharing server to allow guest access to the shared data.

Sharing via network

Earlier, we mentioned that sharing via network is only possible for Bridged and Host-only network. Let's see two examples. The first step is to allow sharing in the guest machine.

Then, you access the virtual machine via its IP address.

On Windows:

On Windows, use Start> Run> \\XXX.XXX.XXX.XXX and replace the triplets of Xs with the actual IP of the virtual machine.

On Linux:

Type smb://XXX.XXX.XXX.XXX in the address bar of the file manager. smb:// stands for the Samba network protocol. The triplets of Xs stand for the IP address of our guest machine.

With Bridged networking, it looks like this:

With Host-only, it looks like this:

Ignore the title Windows shares. Samba is usually used to share with Windows hosts. NFS is more typically used for Linux machines. Samba is preferred, because it works with both. For more about Samba sharing, please take a look at this tutorial.

Shared Folders

추신 All of the above is identical for Windows and Linux guests, by the way. To this end, I decided to take the last set of screenshots demonstrating Shared Folders on a Windows machine.

Now, Shared Folders are quite simple to setup. Your first step is to configure a folder on your host that you wish to share. For any virtual machine, open the Settings menu and go to Shared Folders.

In the right pane, you will have a list of all shared folders on the machine. You can add and remove them as you see fit. The little icons to the right are used for that purpose.

Folder Path:

This is the actual, physical path that you wish to share. On Windows, the folder path will be something like C:\shared. On Linux, it will look something like /home/roger/shared.

Folder Name:

This is the name of the share that your guests will see. Please use names without spaces, something like Shared-folder or Banana. This name can be identical to the actual folder you're sharing, but it does not have to be. But please note, this is not a path! It's a symbolic name for virtual machines to use, as they do not see your physical hardware.

Once you've created the path, boot you virtual machine.

On Windows:

If your virtual machine is a Windows host, you can access the network share either via the command line or using the Tools> Map Network Drive option in the Explorer menu.

On the command line, you need to use the net use command.

net use \\vboxsvr\share-name

net use is the command for mounting network drives.

is the drive that will be assigned the share inside your virtual machine. It can be any free letter, like E:, G:, X:, etc.

\\vboxsvr\share-name is the path to the share. \\vboxsvr is the VirtualBox sharing server. share-name is the actual folder name from earlier. So if you called your share Rambo, then the path reads \\vboxsvr\Rambo.

The command then looks like:

net use h:\\vboxsvr\Rambo

Via the Tools menu in the Explorer, it looks like this:

You can check Reconnect at logon, so you don't have to repeat this task every time you power on the virtual machine. Once you click Finish, you will have a new drive under your My Computer. Opening this new drive letter will take you into the Shared folder.

On Linux:

This is done by a simple command in a terminal windows:

mount -t vboxsf share mount_point

vboxsf is the pseudo-filesystem type used to mount the Shared Folder. It's an abstract translation layer for the virtual sharing service used by VirtualBox.

share is the name of the folder from earlier. Remember, the name and not the path! For example, if our share is called Banana then share =Banana.

mount_point is any directory in your Linux tree where you wish to mount the Shared folder to. For example, /home/roger/shares-go-here.

Thus, our command looks like:

mount -t vboxsf Banana /home/roger/shares-go-here

And then, everything that is inside the shared folder on your host will be visible inside the virtual machine by going to the above path.

To automate the task, you can add the mount option to the /etc/fstab menu. Again, for more details on how to do this, please refer to my Linux commands tutorial.

BTW, notice the help in the Settings menu, explaining how to achieve this!

그리고 그게 다야.

결론

Now, you know everything you need to know about VirtualBox network &sharing. Windows, Linux, bridged, host-only, NAT, sharing via network, sharing via Shared Folders, you name it, you have it all. I hope you have enjoyed this tutorial.

Stay tuned for more good stuff.

건배.