Computers Windows Internet

Configuring a virtualbox virtual machine network bridge. Wmware workstation network setup in virtual machines. LAN segment

It all started when I needed to run Wordpress in a sandbox. The easiest was to create a virtual Ubuntu 11.10 server as a guest inside the VirtualBox host. Then I realized that I knew much less about networks than I thought; the subject is full of packages, switches and routing. I knew even less about networking in VirtualBox, where everything is programmatically virtualized. A few tries and a crash course in networking a little later, mission accomplished to keep you safe from my mistakes, and this is what I found.

Network settings in VirtualBox

Let's install any version of VB, starting from version 3.0, and we will see that the settings window looks approximately the same.

For any of your virtual machines, click Settings> Network. This is the default view.

Any virtual machine can have up to four network adapters that can be enabled as needed. Most of the time, you only need one. Usually, when you create a virtual machine, you can leave it to VB to create one network adapter which will allow you to surf the Internet.

You may find it useful to have multiple adapters of different types, or adapters of the same type with different settings, depending on how you will use the virtual machine and the networks - physical and virtual - to which it is connected.

It's a little more complicated for my virtual web server running Wordpress, so let's get started ... The Adapter type determines the type of virtual hardware available to your virtual machine (VM). VB will try to make sure that the virtual adapter you choose works well with any physical network card which is on your host machine. Let's open the Advanced menu and see additional options. I'll go through the settings deliberately out of order, starting with the Adapter Type.

Adapter Type: VB will try to emulate some of the common types of network cards for which it has drivers and protocols. PCnet-FAST III is the default, although I always go for Intel PRO / 1000MT adapters when looking for good compatibility with Intel hardware. There are two high bandwidth server versions if you are going to run your VM in a production environment. Desktop owners don't have to worry about this. If you're having problems with one adapter, try another, including PCnet-FAST II for older machines.

Mode: The rather colorful sounding "Promiscuous mode" should control the behavior of the virtual router used by the Internal Network; Network Bridge (Bridged) and Virtual Host Adapter (Host Only). You can force the VM's network port to accept traffic directed to other virtual machines, or even a host, in addition to traffic directed to that virtual machine. Promiscuous mode is something that 99% of users do not need to touch, and exists in order to diagnose the causes of some network problems.

MAC Address: Acronym for Media Access Control, MAC address is a hardware address that uniquely identifies each network resource or node on a network. This is a unique identification number that is usually hardcoded on the physical network adapter. VirtualBox generates MAC addresses of virtual machines' network cards.

There is a small button on the right that generates a new MAC address; if you copy a virtual machine, it will need its own unique MAC address to work in your virtual network along with the original.

The Cable connected checkbox does the same as physically connecting or disconnecting a cable. This option connects the virtual adapter to virtual network... It differs from the topmost option, "Enable network adapter", which allows you to install or remove a network adapter from the machine.

Finally, the Port forwarding button opens another dialog that allows you to define the traffic forwarding rules for the adapter; how traffic of a certain type is redirected between the host and the guest machine. This applies only to a few connection types, which will be discussed below. The connection type is determined by the "Connection type" option (with an additional "Name" option), which is the cornerstone of networking in VirtualBox and which gave me a lot of problems at the beginning of my experiment.

"Dragons Live Here"

There are four types of connections and many possible combinations of settings. This is where VirtualBox's networking settings can seem like medieval magic. It's easy to follow the right option to achieve your goal. You can even find several solutions to achieve the same goal.

Connection types

- NAT Network Address Translation
- Network Bridge (Bridged)
- Virtual Host Adapter (Host Only)
- Internal Network

Not connected is also a type, but is used to troubleshoot adapter problems. In this mode, VirtualBox tells the guest that there is an adapter, but there is no connection.

Network Address Translation NAT

NAT allows the guest machine to access the Internet, but through a private IP address that cannot be seen from a host or other location on your physical network. It allows you to browse the web, download files and view mail inside the guest machine, but the outside world can never interact with the guest machine directly.

When the guest machine sends an IP packet to the remote machine, the service NAT VirtualBox intercepts this packet, extracts TCP / IP segments from it, changes the IP address to the IP address of the host machine and sends it. The outside world only sees the IP of the host machine. The host machine receives the response and forwards it to the guest machine.

For example, on your home network, your host and other physical machines usually have addresses starting with 192.168.x.x. In VirtualBox NAT adapters, addresses start from 10.0.2.1, and then up to 10.0.2.24 in the so-called subnet. Usually it is not connected to the main network, therefore the subnet cannot be accessed from the host machine. Your guest machine can access the Internet for updates, surf the web, but is invisible to the rest of your network.

The VirtualBox manual is more transparent:

“In NAT mode, the guest network interfaces are assigned IP addresses from the 10.0.x.0 / 24 range by default, where x is responsible for the NAT interface +2 instance. Therefore x = 2 when only one NAT instance is active. In this case, the guest is assigned an address of 10.0.2.15, the gate is 10.0.2.2, and the nameserver can be found at 10.0.2.3. " (Oracle Corporation, 2012, Chapter 9)

NAT is useful when you don't care what address the guest machine will use. You will need to do some additional configuration when you need to redirect traffic or expose services like a web server to the outside world. In addition, you cannot provide sharing of files and folders on this network.

Bridged Adapter

In Network Bridge mode, virtual machines behave like any other computer connected to the network where the host machine resides; network bridge connects real and virtual networks. The outside world can interact directly with the guest machine.

The network bridge connects through the host system to your network device, which is assigned the IP address of your physical network. VirtualBox connects to one of your installed network cards and exchanges packets directly; it connects the physical and virtual networks. Under normal circumstances it will try to get the standard 192.168.x.x IP address from your router, so your virtual machine looks like a physical device along with other devices on your network.

You can have more than one active network device on your host at the same time; for example my laptop has an ethernet connector on a network card (called eth0) and a wireless adapter (called wlan0). The "Name" option allows you to choose which one you bridged to VirtualBox.

In my case, I am using wireless adapter wlan0 because it's connected to a router while eth0 doesn't even have a network cable connected.

So, my host connects under the address 192.168.0.2 that the router gave it. My virtual machine, connected with a network bridge, appears and requires its IP address, to which the router issues 192.168.2.6 to it, not knowing and not caring that VirtualBox is driving traffic through the adapter of the host machine. My virtual machine becomes just another device on the network. If we count the host machine and three virtual machines connected by a network bridge, then there will be four machines on my physical network.

Come here, here's more ...

NAT is useful because it protects the guest systems from the Internet, but in the event that we need to access them from the host machine, we need to set up port forwarding (I have servers on some of my guest machines). The network bridge provides access, but makes the guest machines open.

If your router, switch, or ISP does not provide you with more than one IP address, then most likely you will not be able to use a network bridge.

Host-only Adapter

Under a virtual host adapter, virtual machines can communicate with each other and with the host machine, but not with the outside world. The virtual host adapter uses its separate networking device, called vboxnet0, to set up the subnet and assign IP addresses to the guest machines. Guest machines cannot communicate with the outside world as they are not connected via a physical network interface. The virtual host adapter provides limited services useful for creating local network under VirtualBox host for guests.

Unlike other virtualization products, VirtualBox NAT does not connect your default network device to your host machine, so there is no direct network connection to NAT-connected machines and no access to applications and data on the host itself. Let's take a look at an example.

Your host has its own network address, the one he uses to access the Internet is usually 192.168.0.101. Under the host virtual adapter, the host machine becomes a router with a default IP address of 192.168.56.1. The host creates an internal LAN so that all guest machines configured for the virtual host adapter are visible on the LAN. The vboxnet0 adapter starts using addresses from 192.168.56.101 onwards, but you can change this in the settings.

Similar to network bridging adapters, virtual host adapters use different address ranges. You can easily allow guest machines to obtain addresses using DHCP (dynamic address allocation, which is likely to change in each session) that VirtualBox provides.

In addition, the virtual host adapter for the host and guest does not have Internet access. They are used to connect the host and guests with a kind of network switch.

Therefore, the virtual host adapter does not provide Internet access to the guest machines; vboxnet0 doesn't have a gate, so while adding vboxnet0 makes it pretty easy network communication host and guests, you will not have external access or port forwarding, so you still need another NAT adapter or network bridge connected to your guest machines to get full access.

Internal network

If you need multiple guest machines to communicate with each other on the same host, but nothing else, then you can use the intranet mode. Although you can use bridging for the same purpose, the internal network is more secure. When using a network bridge, all packets sent and received by the physical adapter on the host machine and traffic can be intercepted (for example, by installing a sniffer on the host).

An internal network creates, according to the VirtualBox manual, "a software network that is visible to selected machines, but not to applications running on the host or in the environment." This gives us a network that has host and virtual machines, but none of them use physical adapters - they are completely virtual and VirtualBox works as a virtual switch. You get a completely private LAN for your guest machines, with no outside access, which makes it very secure. Possible use cases are super-secret development servers and clients, conducting penetration testing, or conversely creating a secure intranet for a team or organization. This is the ideal way to close the space from unauthorized installation of applications, downloads, uploads and hangs on Facebook during the working day.

We now see that different types of networks are suitable for different purposes. Which brings me to where I started - creating a virtual server for development for Wordpress and testing.

Guest Internet Access

To get started, my guest machine needs Internet access to install updates, download packages, and all that stuff. I need access to it from my host machine, but I do not want my server to be accessible from somewhere else on the network.

After finding my machine in the VirtualBox manager, I go to Settings> Network.

I start with standard NAT. It allows the guest machine to access the internet through my host's connection. The guest machine is not visible from my network; I also cannot access the resources of the guest machine from the host machine like other guest machines.

Configuring Virtual Host Adapter in VirtualBox Manager

An easy way is to use the standard virtual host adapter provided by VirtualBox, the one named vboxnet0, but you can add others if you want to use multiple separate networks. If you go to File> Preferences> Network in the main VirtualBox window, you can configure vboxnet0 or add other adapters.

To see the standard settings, click the edit button - this is the button with the screwdriver icon and the caption "Edit host virtual network". The IP address 192.168.56.1 is the address where guests can access the host. I left this setting as it is.

By default, vboxnet0 has a DHCP server configured to automatically issue IP addresses based on sessions. I want my virtual Wordpress server to store a static IP address, so on the DHCP tab I uncheck the "Enable server" checkbox.

Add a virtual host adapter to the guest machine

I will add another network adapter to my guest machine, a virtual host adapter, which includes a self-contained, private, virtual network made up of my host machine and any guests using the virtual host adapter. All machines have access to each other, but nothing from outside can reach them.

On the Adapter 2 tab of my guest machine, I set the Connection Type to the virtual host adapter and the default name vboxnet0. Promiscuous mode is not important, but I need the "Cable is connected" option enabled.

Configuring the guest machine

I need my guest server to have a static IP address on the host's virtual adapter network, otherwise the address will change on every restart and I have to figure out which one it is before I can connect from the host. Log into the guest machine and enter the following command:

ifconfig eth1 192.168.56.101 netmask 255.255.255.0 up

This will set the IP address for the guest and bring up the network interface. It uses 192 is the home networking prefix, .168 is the start of the host ID, .56 is the virtual host adapter network range, and the last identifier, any greater than 1 (my host) on my virtual host adapter network. The NAT adapter is on eth0, so the virtual host adapter is connected to eth1. Now I can SSH or log into the guest machine from the host using the IP address.

A port during a storm?

The networking pros have already seen an alternative way to get to my virtual server.

Using a NAT adapter, I can manipulate the configuration to access my virtual server from the host without using the virtual host adapter.

I can configure Port Forwarding in VirtualBox using the Guest Network Adapter Settings panel. We switch to the NAT adapter, the big button at the bottom is "Port Forwarding". It opens a configuration window where I can configure port forwarding for this adapter of this particular guest machine.

I need two rules; one for accessing the Apache webserver on my guest, another for handling TCP traffic (mostly http requests).

For simplicity, I've named them Apache and TCP, and they both use the TCP protocol. If we return to the usual port numbers, then 8888 on the host is transferred to 80 guest machines, then 2222 on the host to port 22 of the guest machine; this opens up special access to the guest machine for service requests. All other requests will be rejected by VirtualBox because the path cannot be found.

This also means that all other guests that I start will not be able to access this virtual server since there is no network path under NAT.

Not so long ago, we wrote about a great virtualization program - VirtualBox. Since at that time we were not even going to connect the virtual machine to the Internet, we omitted this issue until better times. And finally, a miracle happened. We bring to your attention one of the options for setting up the Internet in VirtualBox using an example of a real computer network.

(mosloadposition debug)

As an example, we took VirtualBox 2.1.0 with a stable working network. Our VirtualBox is installed in the operating room Windows system Vista, and we installed Windows XP SP2 on the virtual machine created in VirtualBox.
A Windows Vista computer is connected to the Internet through a gateway with the address 192.168.0.100. This gateway distributes the Internet to all computers on the local network via wi-fi. The gateway and wi-fi settings are not relevant, so we will not dwell on them, but go straight to the point.
First of all, let's check on our real computer the properties of a real network connection through which it interacts with the Internet. So, in Windows Vista, open "Start" - "Control Panel" - "Network and Sharing Center" - "Manage network connections".
Let's click right click mouse on the name of the network connection through which the PC is connected to the Internet or local network, and select Properties. On the Network tab, the VirtualBox Host Interface Networking Driver item must be enabled. If the checkbox is not checked, you need to put it and click "OK".

Now let's get into the firewalls - we need to allow them to release VirtualBox on the network. In the built-in Windows Firewall ("Start" - "Control Panel" - " Windows firewall») VirtualBox must be added to the exceptions list. If another firewall is installed on the computer, for example, Agnitum Outpost, turn it on in training mode, because later we will have to allow VirtualBox to connect to the network and create the appropriate rules. It would be better if the firewall asks us about this, rather than silently blocking all VirtualBox attempts to go online.
On this we leave alone the real operating system and turn our attention to VirtualBox. We need to add a network adapter to the virtual machine and configure it: select the virtual machine in the VirtualBox list and click the "Properties" button.

In the list on the left, select the "Network" section. On the "Adapter 1" tab, check the box next to "Enable network adapter". You can choose the type of adapter, as in the screenshot, but you can also experiment by choosing different adapters from the list.
In the list "Attached to:" select "Host interface". This means that the network card of the virtual operating system will interact with the Internet and the local network directly.
We want to say right away that you can choose other settings, but by the method of a scientific experiment, we managed to make the Internet work only in this way. This is because the settings of the virtual network are closely related to the configuration of your Internet connection and your real computer network. In each case, you will have to experiment. But most of all, using the options indicated in the screenshot, we managed to get the Internet working in VirtualBox.
Do not forget to check the box next to "Cable is connected", and in the list of host interfaces below, select the network card of our real computer through which it is connected to the Internet or a local network.
This completes the addition of the network adapter to the virtual machine. Click "OK" to apply the settings.

We launch the operating system created in VirtualBox (we have it Windows XP SP2). Now we have to configure the previously added network adapter. In Windows XP, these settings are available through "Start" - "Settings" - "Control Panel" - "Network Connections".
In the list network connections find "Local Area Connection", right-click on it and select "Properties".

On the "General" tab, in the list of components used by the connection, select "Internet Protocol (TCP / IP)" and click the "Properties" button.

The settings below depend entirely on your network configuration. As we already said, we have a gateway with the address 192.168.0.100, which distributes the Internet to the entire local network. Therefore, our virtual computer must fit into the configuration of the real network and have the address 192.168.0.X, where X is any digit from 1 to 254 that is not found in any other address of the computers on the network. Since we already have a computer with the address 192.168.0.100, we can choose any number from 1 to 254, except 100.
In our example, the choice fell on the address 192.168.0.77. The subnet mask is entered automatically, just click in this field with the mouse. In the "Default gateway" field, enter the address of the computer that distributes the Internet or the provider's gateway. In the "Preferred DNS server" field, enter the address of the corresponding server. It can be the same as the gateway address or not. If your network has another (alternative, secondary) DNS server, enter its address in the field below.

This completes the configuration of the network connection in the virtual operating system. Click "OK".
Now you need to check the connection with the gateway. Open "Start" - "Run" and enter the command "cmd" in the field (without quotes and in English).

The Windows command interpreter will open. We type "ping 192.168.0.100" (without quotes), where 192.168.0.100 is the address of the gateway or another computer on the network with which you want to ping from virtual machine... If you see that a response has been received from the gateway, then the Internet is working. Now you can enjoy surfing on world wide web straight from VirtualBox.

If there is no response from the gateway or any other computer on the network, it is worth changing the settings to more appropriate for your network. Everything is in your hands here.

Learning to use VirtualBox is good for everyone. Thanks to this service, you get virtual computers that you can run on your devices without having to buy new hardware. At its core, it is free virtualization software.

VirtualBox was created to solve many problems. Thanks to this functionality, you get the opportunity to create virtual computers "out of thin air". They don't take up space on your desk, but they work just like a real PC. They can be created and deleted with a few clicks.

What is VirtualBox? It is a free open source cross-platform application for creating, managing and running virtual machines (VMs) - computers whose hardware components are emulated by the host computer or the device on which the program is running. VirtualBox can run on Windows, Mac OS X, Linux, and Solaris.

Why is this needed?

Using virtual machines can be extremely beneficial for a number of reasons. For example, you can run it to try software that you think might be dangerous, or try a different operating system without changing the way your computer is configured.

You can also use it for security purposes. For example, you can create an online banking-only virtual machine to make sure you don't fall victim to spyware or Trojans receiving your data.

How do I install VirtualBox?

The easiest way to get latest version VirtualBox - Download it from the download page of the official website. There you can find a suitable version for your platform or? if you are using Linux, you can check the list of instructions for different Linux distributions.

For each version of Linux, you are given the option to download the option "i386" or "amd64", 32-bit and 64-bit, respectively.

How do I install VirtualBox? This process is similar to installing any other program on your platform, so you shouldn't have any problems. If you are experiencing any difficulty, you can always read the installation guide on the service website.

Using VirtualBox

How do I use VirtualBox? When you launch the application for the first time, you will be greeted by the VirtualBox Manager. Here you can create virtual machines, enable or disable them and configure access to virtual hardware available to them, as well as configure the network.

Creating a virtual machine

In order to configure the network in VirtualBox and get started, you need to create a virtual machine. This is done in the following way.

The first step to creating any virtual machine is to click the New button in the upper left corner of the VirtualBox Manager window - this is a big blue star that is very difficult to miss.

This will launch the "New Virtual Machine Wizard", which will guide us through the steps required to start.

Enter your name virtual computer... This name is completely up to you, but there are some nuances.

VirtualBox will try to figure out what OS you plan to run in the virtual machine based on what name you enter. If the name is referred to as "XP", it is assumed that you will be installing Windows XP and configuring it accordingly. However, you can come up with a random name. Then you will have the option to manually select your OS type from the drop-down lists below. When you are done, click Continue to proceed to the next step. This example focuses on Windows for VirtualBox. Below are instructions for installing this OS as a guest and then setting up a network connection.

Choice of RAM

To install the guest OS after starting VirtualBox, you will be prompted to select a volume random access memory that you want to host in the virtual machine. The more you give her volume, the more better app will work, but keep in mind that the memory allocated for the virtual machine cannot be used by the host OS (that is, the machine on which VirtualBox is installed).

So how much RAM should you allocate to a VM? It depends on a number of factors. If you only plan on using the virtual machine while it is running, you can afford to give it more RAM because you won't be asking the host to multitask. If, on the other hand, you will be using it concurrently with many other functions on the host OS, you should better calculate this value. A good general rule of thumb is to allocate half of your computer's RAM. So, if your PC has 4GB of RAM, give 2GB of VM, leaving the host with the rest. If you select this value with a gross error, you will face the fact that VirtualBox does not start.

Storage space

The next step is to create a “virtual hard disk"(VHD). This creates a file on your HDD that VirtualBox can use to act as a separate HDD... This allows you to install the operating system without worrying about your existing data being harmed.

Make sure Boot Hard Disk and Create new hard disk ”, then click“ Continue ”. This will launch "Create New Master virtual disk". Click Continue again to complete the action.

You will then be asked if you want to create a "dynamically expanding" or fixed size disk. Each has its own advantages. The great thing about a dynamic disk is that it only takes up as much data as it contains. It is also much faster to create than a fixed size of any significant size.

However, you need to watch out for this, because its flexibility can also be its negative trait. So, you create a dynamic disk and assign 50 GB to it, and then put about 20 GB of data on it. Its file will show up as only holding 20GB of hard disk space, according to your host OS. Therefore, you can take this place with other data and not notice it.

The point is, if you start the virtual machine and try to add more data to the dynamic disk, you will run into problems - the virtual disk says that it still has 30 GB, but in fact it may not be there anymore.

This is also the advantage of a fixed size disk. Of course, it is inconvenient when you are trying to figure out how much space you will need, but then you no longer have to worry about it.

This example shows dynamic disks, but fixed disks will work just as well. Make sure Dynamically Expanding Storage is selected, then click Continue again. Next, you will be asked to select the name, location and size of the new VHD. For most uses, you won't need to change the name or location, but you can do so by clicking on the folder icon next to the text box.

The size you must specify depends on how much material you plan to use. If you just want to use it to run multiple programs, the suggested 10GB size should be fine. Make sure the settings are correct, then click Continue and Finish.

At this point, you just need to check everything and make sure that all settings are set as you expect. Then you just need to click Finish and the virtual machine will be created so you can install Windows.

Booting guest OS into VirtualBox

How to use the service further? Now it's time to start the virtual machine for the first time. Make sure the new virtual PC you just created is selected in the VirtualBox Manager window, then click the Start button at the top of the window. When the service starts, you will be greeted with the First Run Wizard, which will help you prepare for installing Windows XP. Click Continue. Then it will ask you what you want to use as the installation media - a CD or an image on your hard drive (usually as an .iso file). Once you've chosen your option, click Continue, then Finish.

If you were unable to open the VirtualBox virtual machine after the above settings, it is likely that you have incorrectly allocated space for RAM or HDD. If restarting does not solve the problem, repeat the previous steps again.

Since nothing is installed on the virtual hard disk, the program will automatically load Windows installations... It will take some time to load all the required OS files, but eventually you will see a screen that displays a list of existing partitions and unallocated space on the computer.

After that, you have to configure XP, so press Enter. This will ask you how you want to format the drive. You need to select the option "Format the partition using file NTFS systems(Quick) ". Make sure you select the "Fast" option, or you will be waiting for a very long time!

Windows Setup will then format the VHD and then start copying files to disk. Your participation in this process is not required. After copying the files is complete, Windows Setup will automatically restart your computer to proceed to the next step.

When the PC restarts, it will try to power on from the CD using the Press any key to boot from CD ... window. Ignore this! If you do, you will repeat the previous step again for no reason.

You can prevent this system issue by right-clicking the CD icon at the bottom of the virtual machine window and clicking Remove Disk from Virtual Disk. Once this window is closed, you will see the familiar screen. Windows boot XP before it switches to the second stage of the installation.

Once the "Windows XP Setup Wizard" is displayed, click "Next" to start it. First, you will be prompted to set the regional and language settings, which are mainly related to clicking "Configure ..." (to select a country), and then "Details" if you need to change the keyboard layout.

After everything is selected, click "Next" again. After that, you will need to enter the computer name and administrator password. Better to choose a name that makes some sense, instead of a random string of automatically generated characters. How complex you want to make the administrator password depends on how important the security of the virtual machine is.

After clicking "Next" you will see the date and time settings that you do not need to change. When you press this button again, the window will disappear for a while, Windows will apply all the settings and continue with the installation. You can now use Guest Additions in VirtualBox.

After a minute or two, another window will appear, this time for the network settings. It is more convenient to choose the first option (a network that does not have a domain). To do this, you need to enter a name working group- defaults to Rward, and all defaults. However, you may need to select "Direct3D Support" when asked to define components.

How to work with the network?

Networking in VirtualBox is extremely efficient, but setting it up can be a little tricky. To understand this, you need to consider different ways VirtualBox networking settings with multiple pointers on what configurations to use and when.

Oracle VM VirtualBox 5.1 allows you to configure up to 8 virtual network adapters (controllers network interface) for each guest virtual device (although there are only 4 in the GUI).

Main modes:

  • Network Address Translation (NAT).
  • Bridge networks.
  • Internal network.
  • Host-only network.
  • NAT with port forwarding.

Oracle VirtualBox offers them as based on the guest OS type you specify when you create the virtual machine, and you rarely need to modify them. But the choice of network mode depends on how you want to use the device (client or server) and whether you want other computers on your network to see it. So, you should look at each VirtualBox networking mode in a little more detail.

Network Address Translation (NAT)

This is the default mode for new virtual machines and works great in most situations where the guest OS is a "client" type (that is, most network connections are outbound). This is how it works.

When the guest OS boots up, it usually uses DHCP to obtain an IP address. Oracle VirtualBox will send this DHCP request and inform the operating system of the assigned IP address and gateway address for routing outbound connections. In this mode, each virtual machine is assigned the same IP address (10.0.2.15) because they each think they are on their own isolated network. And when they send their traffic through the gateway (10.0.2.2), VirtualBox rewrites the packets so that they appear as if they came from the host and not from the "guest" (running inside the host).

This means that the guest OS will work even if the host moves from network to network (like a laptop moving between locations), from wireless to wired connections.

However, how does the other computer initiate a connection to it? For example, you need a connection to a web server running on a guest computer. This is not possible (usually) using NAT mode as there is no route to the guest OS. Thus, for running virtual machine servers, you need a different network mode and a different VirtualBox network setting.

NAT connection (network characteristics):

  • Guest OSs are on their own private network.
  • VirtualBox acts as a DHCP server.
  • VirtualBox NAT mechanism translates addresses.
  • Target servers display traffic originating from the VirtualBox host.
  • No configuration required for host or guest OS.
  • Works great when "guests" are clients but not servers.

Bridge networks

Bridged Networking is used when you want your virtual machine to be a full-fledged network element, that is, equal to your host device. In this mode, the virtual network adapter is "connected" to the physical one on your host.

This is because each virtual machine has access to the physical network just like your host. It can access any service on the network — external DHCP services, name lookup services and routing information, and so on.

The disadvantage of this mode is that if you run many virtual machines, you can quickly run out of IP addresses or your network administrator will be flooded with requests for them. Second, if your host has multiple physical network adapters (such as wireless and wired), you must reconfigure the bridge if it reconnects on the network.

What if you want to run servers in a virtual machine but don't want to involve a network administrator? Maybe one of the following two modes is right for you, or you need a combination of additional parameters, such as NAT vNIC + 1 Host-only vNIC.

Bridged network characteristics:

  • VirtualBox bridges are for the host network;
  • good for any guest OS (both client and server);
  • use IP addresses;
  • may include guest configuration;
  • best suited for production environments.

Internal network

When you configure one or more virtual machines to run on an internal network, VirtualBox ensures that all traffic on that network remains inside the host and is only available to a device on that virtual network.

The internal network is a completely isolated system. It is well suited for testing. In it, using a virtual machine, you can create complex internal networks that provide their own services (for example, Active Directory, DHCP, etc.). Note that even the host is not a member of it.

This mode allows the virtual machine to run even when the host is not connected to the network (for example, on a plane). However, with this type of connection and network configuration, VirtualBox does not provide such "convenient" services as DHCP, so your device must be statically configured or provide a DHCP / Name service.

Installation of several internal networks is allowed. You can configure virtual machines so that multiple network adapters can reside in internal and other network modes, and thus provide routes if necessary. But all this looks complicated and inaccessible to the layman.

What if you want the internal network to host a VirtualBox host by providing the guest OS with IP addresses? To do this, you may need to configure the host-only network.

Internal network characteristics:

  • guest operating systems can see other "guests" on the same internal network;
  • the host cannot see the internal configuration;
  • network configuration is required;
  • even if the host is not a member of the connection, the internal network can be shared with the bridged connection;
  • well suited for multiplayer network.

Host-only network

Works in much the same way as an Internal Networking connection, in which you specify which network the guest server is on. All virtual machines on this network will see each other and the host. However, other external devices cannot see “guests” on this network, hence the name “host only”.

It is very similar to an internal network, but the host can now provide DHCP services. To set up such a connection, go to VirtualBox Manager and select the default settings.

Network characteristics:

  • VirtualBox creates a private internal network for the guest OS and the host sees the new NIC software.
  • VirtualBox provides a DHCP server.
  • Guest operating systems cannot access the external network.

NAT with port forwarding

Now you can imagine that you have learned enough modes to handle each case, but there are exceptions. What if the development environment is, for example, on a laptop and you have one or more virtual machines that need other computers to connect? And you are constantly forced to use different client networks.

In this scenario, NAT will not work because the outside machines must be bridged. This is probably a good option, but you may need IP addresses. In addition, software is not always able to cope with changing networks.

If you use an internal network, it may turn out that your virtual machines need to be visible on the network. What to do in such cases?

Configure the virtual machine to use a NAT network, add port forwarding rules, and external computers connect to "host". The port number and connections will be forwarded by VirtualBox to the guest OS number.

For example, if your virtual machine runs a web server on port 80, you can configure the above rules. This provides a mobile demo system that does not need to be reconfigured every time your laptop connects to a different LAN / Network.

Ultimately, VirtualBox has a very powerful set of options, allowing you to tweak just about any configuration you might need. To find the option you need, study the VirtualBox instructions on the official website.

First, install any version of VirtualBox virtual machine starting from 3.0. And you will find in it about the same possibilities compared to those described in this article.

After installing the program, go to the “Settings - Network” menu. The appearance of the opened tab corresponds to the default settings. Any of the virtual machines can be configured to use four network adapters - depending on which one you need in your particular case. But more often than not, in practice, only one of them is required. Typically, when you install a virtual machine, a simple network adapter is created by default. This is enough for Internet access.

Depending on the needs, it may be necessary to create several network interfaces of different types. Or several devices of the same type, but with different settings. This may be required for both physical and virtual network adapters to be used on the virtual machine. It all depends on which ones are connected.

For my web server running CMS WordPress on it, things are a little more complicated, so let's move on ... The “Adapter Type” tab is responsible for configuring the virtual hardware... VirtualBox does an excellent job of acting as a link between a software network card and the physical interface installed on a real machine (host). Open the "Advanced" link and you will have access to the advanced capabilities of the network adapter. In this article, I will describe in detail all the settings in the order they appear, starting with setting the adapter type.

Adapter Type

The VirtualBox virtual machine has built-in software emulation of most of the most common types of network cards, for which drivers and protocols are created. The PCnet-FAST III card is the default choice, however in my practice I often choose the Intel PRO / 1000MT. I do this when I want the best possible compatibility with the Intel hardware that is installed on my computer. If you have any problems configuring your network connection, you can try changing the adapter type by choosing a different one. For the most ancient equipment, the PCnet-FAST II network card is suitable.

Mode (Mode)

The rather odd-sounding “Promiscuous Mode” is usually used for the VM to act as a virtual router on LANs; as a network bridge or host. In this mode, the virtual machine port is able to receive any packets sent for other operating systems; and even for the host. That is, network packets are accepted that are intended not only for this adapter, but also for other network devices. In 99% of cases, ordinary users do not need “Illegible Mode”. It is used by network administrators to diagnose network problems.

MAC address

The MAC address (MAC stands for Media Access Control) is the unique “name” of a device on a network that uniquely identifies and distinguishes it from other adapters and nodes. This address is written for each network device at the physical level in the memory of the interface itself. When creating a virtual network adapter, VirtualBox will automatically generate a MAC address for it.
If you need to change an existing MAC address, then this is done by a small button on the right, which generates a new value. In the case of cloning an existing virtual machine, you need to create its own unique MAC address for it, which will be different from the address of the original machine.

A check mark opposite the inscription “Cable is connected” performs the same role as connecting or disconnecting a physical cable in reality. This setting is responsible for connecting the virtual network adapter to the network. It should not be confused with the other more important "Enable network adapter" setting, which enables or disables the adapter itself in the virtual machine.

The "Port Forwarding" button opens a dialog box in which the traffic behavior rules on a specific adapter are configured; how traffic of a certain type will be moved between the host and the guest virtual machine. These rules apply to network models, which will be discussed a little later. The network models themselves are defined on the "Connection Type" tab. This setup is the most difficult part of establishing connections in VirtualBox. She gave me the most trouble in my experiments.

Network connection types

There are four ready-made models for connecting to the network in VirtualBox:

  • Network Address Translation (NAT), which is the default setting
  • Network Bridge (Bridged)
  • Virtual Host Adapter (Host Only)

The Not Connected connection is also a network setting, but it serves only one purpose - to identify possible problems. In this mode, VirtualBox tells the guest operating system that a network card is present, but there is no connection to it.

Network Address Translation (NAT)

NAT protocol allows the guest operating system to access the Internet using a private IP that is not accessible from the outside network or to all machines on the local physical network. This network setting allows you to visit web pages, download files, view email... And all this using the guest operating system. However, it is impossible from the outside to connect directly to such a system if it uses NAT.

The principle of network address translation is as follows. When the guest OS sends packets to a specific address of a remote machine on the network, the NAT service running under VirtualBox intercepts these packets, extracts from them the segments containing the sending point address (the IP address of the guest operating system) and replaces them with an IP address. host machine address. Then it repackages them and sends them to the specified address.

For example, on your home LAN, the host and other physical network devices have addresses in the range starting with 192.168.x.x. In VirtualBox, NAT adapters have IP addresses ranging from 10.0.2.1 to 10.0.2.24. This range is called a subnet. As a rule, this range is not used for assigning addresses to devices on the main network, therefore such a system is not accessible from the outside, from the host side. The guest OS can perform software updates and surf the web, but remains invisible to the rest of the “participants”.

The VirtualBox manual describes this point in more detail:

“In NAT mode, the guest network interface is assigned by default an IPv4 address from the 10.0.x.0 / 24 range, where x denotes a specific NAT interface address, determined by the formula +2. Thus, x will be equal to 2 if there is only one active NAT interface. In this case, the guest operating system is assigned an IP address of 10.0.2.15, the network gateway is assigned an address of 10.0.2.2, and the name server (DNS) is assigned an address of 10.0.2.3. ” (Oracle Corporation, 2012, Chapter 9).

NAT is useful when there is no difference in which IP addresses the guest operating systems in the virtual machine will use, since they will all be unique. However, if you need to configure redirection of network traffic, or expand the functionality of the guest OS by deploying a web server on it (for example), then additional settings are required. Features such as sharing folders and files are also not available in NAT mode.

Network Bridge (Bridged)

In a Network Bridge connection, the virtual machine behaves like all other computers on the network. In this case, the adapter acts as a bridge between the virtual and physical networks. From the side of the external network, it is possible to directly connect to the guest operating system.

The adapter in the "Network Bridge" mode is connected, bypassing the host, to a device that distributes IP addresses within the local network for all physical network cards. VirtualBox connects to one of the installed network cards and sends packets through it directly; it turns out the work of the bridge over which the data is transmitted. As a rule, the adapter in the “Network Bridge” model receives a standard address from the 192.168.х.х range from the router. Therefore, a virtual machine on the network looks like it is an ordinary physical device, indistinguishable from the rest.

Several network devices can be active on a host at the same time; for example my laptop has a wired connection (called eth0) and wireless connection(called wlan0). The Name field allows you to select which of the network interfaces you would like to use as a bridge on VirtualBox.

In my case, I am using the wlan0 wireless adapter since it is connected to a router. Whereas the eth0 wired interface doesn't even have a cable.

Therefore, my host is assigned an IP address of 192.168.0.2 by the router. The virtual machine in the "Network Bridge" mode is assigned the address 192.168.2.6. It does not matter that VirtualBox transmits and receives traffic as if "through" the host, bypassing it. As a result, it turns out that the virtual machine becomes just another computer on the local network. If I recalculate my computer and three virtual machines (VMs) operating in the "Network Bridge" mode, then I get four computers on the physical LAN.

NAT is useful because it protects guests OS from the Internet. But in order to access them from the outside (and on some OS I have installed web servers), I need additional customization to redirect traffic. The "Network Bridge" connection type allows access to them, but in this case the systems become unsecured.

If your network access device (it could be a router, network switch, or the settings provided by your ISP) allows you to provide only one IP address for the network interface, you may not be able to configure “Network Bridge”.

Virtual Host Adapter (Host-only)

With a "Virtual Host Adapter" connection, guest operating systems can communicate with each other as well as with the host. But all this is only inside the VirtualBox virtual machine itself. In this mode, the host adapter uses its own dedicated device called vboxnet0. They also create a sub-network and assign IP addresses to the network cards of the guest operating systems. Guest operating systems cannot interact with devices located on the external network, since they are not connected to it through a physical interface. Virtual Host Adapter mode provides a limited set of services useful for creating private networks under VirtualBox for its guest operating systems.

Unlike other virtualization products, the NAT adapter in VirtualBox cannot act as a bridging bridge between the default network device on the hosts. Therefore, direct access from the outside to machines "hidden" behind NAT is impossible - nor to the programs running on them; nor to the data residing on the hosts themselves. Let's take a look at the following example.

Typically, a host has its own network address, which is used to access the Internet. This is usually 192.168.0.101. In “Virtual Host Adapter” mode, the host machine also acts as a VirtualBox router and has a default IP address of 192.168.56.1. An internal LAN is created to serve all guest operating systems configured for Virtual Host Adapter mode and visible to the rest of the physical network. The vboxnet0 adapter uses addresses in the range starting with 192.168.56.101. But if you want, you can change the default address.

Like an adapter in Network Bridge mode, Virtual Host Adapter mode uses different address ranges. You can easily configure guests to obtain IP addresses using the built-in DHCP server of the VirtualBox virtual machine.

In addition, it must be said that in the "Virtual Host Adapter" mode, the network created by him does not have an external gateway to the Internet, both for the host and for the guest operating systems. It works just like a normal network switch, connecting the host and guest systems together. Therefore, the adapter in “Virtual Host Adapter” mode does not provide Internet access to the guest machines; vboxnet0 does not have a gateway by default. Additional features for this adapter greatly simplifies the network configuration between the host and the guest OS, however, there is still no external access or port forwarding. Therefore, you may need a second adapter in Virtual Host Adapter or Network Bridge mode that connects to the guest operating system to receive full access To her.

Internal Network

If in practice you need to configure the relationship between several guest operating systems running on the same host and can communicate only with each other, then you can use the "Internal network" mode. Of course, you can use the Network Bridge mode for this purpose, but the Internal Network mode is more secure. In Network Bridge mode, all packets are sent and received through the physical network adapter installed on the host machine. In this case, all traffic can be intercepted (for example, by installing a packet sniffer on the host machine).

The internal network, according to the VirtualBox manual, is “ program network which may be visible to selectively installed virtual machines, but not to applications running on the host or on remote machines located externally. " Such a network is a collection of a host and several virtual machines. But none of the above devices have an output through a physical network adapter - it is completely software, used by VirtualBox as a network router. In general, the result is a private local area network only for guest operating systems without Internet access, which makes it as secure as possible. A possible application for such a network is a top-secret server with clients for development; penetration testing of systems or any other purpose aimed at creating an internal network for development teams or organizations. This is an ideal way to block your environment from unauthorized software installation, downloading or uploading files, or visiting services like Facebook during business hours.

So, we looked at the different types network connections... Each of them has its own settings and is intended for specific purposes.

PC users can use in their work different types operating systems. Sometimes it is very necessary, while in one OS, to use the functions of another, but a reboot is undesirable. There is a great solution - "virtual machines". Among the most famous in the global IT market is VirtualBox. What are its features? How is the network setup required to work with VirtualBox?

What is VirtualBox

VirtualBox is, as we noted above, a "virtual machine". In other words, it is software environment, which allows loading one or another operating system in almost full-featured mode while the user is in the interface of another OS.

That is, for example, if a person has Windows, he can, using VirtualBox, run (and before that - install) Linux on a PC without rebooting. The practical usefulness of this function may lie, for example, in the fact that when working with Windows programs, you can fully use the functions of the server operating systems of the Linux line, which in some cases are indispensable. By the way, the reverse procedure is also possible.

The full name of the "virtual machine" in question is Oracle VM VirtualBox, since it was developed by the famous American corporation. Let's consider the main features of the Oracle solution.

VirtualBox features

VirtualBox is a great alternative to solutions such as Wine, used when a Linux user needs to run a Windows program. However, using Wine does not guarantee successful launch of Windows-based software. In turn, the "virtual machine" allows you to load the corresponding OS interfaces from Microsoft and use them with practically the same functionality as when booting Windows separately.

So, when solving control problems, such opportunities are extremely in demand. The most important thing to fully exploit the potential of Windows or Linux through VirtualBox is to configure the network in accordance with the correct algorithms.

Terms of use

One of the main advantages of VirtualBox is that it is free. Wherein this decision is actually produced in a single version, and therefore, having mastered the intricacies of working with it, you can easily use it later, without fear that the developer will release fundamentally new interfaces. Note, however, that Oracle has created an additional package to the "virtual machine" - Expension Pack, which includes solutions such as, for example, an RDP server, with which you can connect to a virtual machine remotely using the appropriate type of protocol. An advanced package for VirtualBox for personal use - that is, under the condition of non-commercial use - is supplied to enthusiasts of useful IT solutions free of charge.

Possibilities

What are the most notable features of VirtualBox?

First of all, this is virtualization on platforms like x86 - you do not need support for Intel VT, as well as AMD-V.

The program is characterized by an intuitive user-friendly interface. Russian language is also supported in VirtualBox. Setting up the network and solving other problems, thus, will be facilitated for Russian users.

VirtualBox is a cross-platform solution. It is suitable for Windows, Linux, Mac OS.

There is support for processors with multiple cores, as well as computers in which multiple corresponding chips are installed.

There is Guest VM Additions, which allows you to optimize communication with the OS on which the program runs.

The performance of the virtual machine, according to many IT professionals, is at the highest level.

One of the key tasks in preparing to work with VirtualBox is network configuration. Let's consider the main nuances of its solution.

Installing a virtual machine

So, we have to configure the VirtualBox network. Let's study the key nuances of installing it on the user's computer, as well as the algorithms for the basic stages of setting up this software. First, you need to download the distribution kit of the program from virtualbox.org and install the solution on your PC. What nuances can accompany the solution of this problem? For example, you should confirm the installation of the virtual interface required for network operation. In this case, the actual connection can be temporarily deactivated.

Key virtual machine settings

Next, we launch the program. The main window of the interface will display a list of virtual machines that can be run on a PC. The very first time the program is loaded, it will most likely be empty. Therefore, the user will need to create a virtual machine on their own. To do this, press the appropriate button, then select the type of virtual machine and its name. The OS that many users prefer to run on VirtualBox is Ubuntu. Setting up a network with its help is carried out fairly quickly, the nuances accompanying it are easy to master.

After choosing the type of virtual machine in the settings, you must specify how much RAM the program can use. The recommended size is 1 GB. After that, you need to create a virtual disk space - this is done on the computer's hard drive. To do this, you need to specify in the settings that a file type such as VDI will be used. It should also be noted in the program that the disk will be dynamic. After that we indicate the size of the hard drive, for example, 8 GB (to run a "virtual machine" does not need too much disk space).

Let's take a look at how to set up a "virtual machine" from Oracle. It can be run in the interface of almost any version of Windows, including the most widespread in the world - Windows 7.

Basic nuances of setting up VirtualBox in Windows 7

After installing the program, for example, in Windows 7, you will need to configure some of its key options. In the main window of the VirtualBox interface, right-click on the created "virtual machine" and select the "Properties" option. The key point that interests us in the corresponding interface is the type of buffer between two systems: base and guest. The corresponding option can be found in the General tab. It is best to tell the program to use a bidirectional buffer.

It is also useful to select the "File" menu item, then go to "Settings". In the "General" section, select the "Folder for machines" list. We mark the "Other" option and specify the folder where the virtual machine files will be located. In the "Input" section, you can configure the key with which keyboard input and mouse manipulations are redirected to the interfaces of the virtual machine. You can also customize the display - for example, in terms of the maximum

Launching VirtualBox and installing a second OS

After basic settings produced, you can run the "virtual machine". To do this, select its name from the list in the main menu and click on the "Start" button. After that, an interface will open with which you can install the required OS. Its distribution kit, therefore, must be ready - for example, in the form of a CD or DVD. After the OS is installed, we can proceed to such a stage as the direct configuration of the VirtualBox virtual network.

Network setup: key options

You must select the type of virtual OS and click the "Configure" button. After that, go to the "General" tab. Here we are interested in the "Network" section. You must select a connection type such as bridge. It assumes that a channel will be formed between the PC's network card and the virtual machine, with the help of which the corresponding resource of the current OS can be used in another operating system. Note that in the section “ Shared folders»You can manage the corresponding items for storing files that appear in the process of exchange between the PC and the virtual machine.

Setting up a network in a "virtual" Ubuntu OS

As we noted at the beginning of this article, the optimal virtual environment when using VirtualBox is Ubuntu. Network configuration by using this operating system can be implemented within the framework of the following algorithm. To begin with, you should download one of the OS versions that is best adapted to solve the problem in question. Go to releases.ubuntu.com, then select the 14.04 LTS version. After that, you should download the ISO image of the operating system. If the user has a 64-bit PC, then the appropriate type will be needed. Next, using the VirtualBox interface, you need to start the OS installation process (above we examined how this mechanism works). After installing "virtual" Ubuntu, we move on to the main steps of such a procedure as configuring the VirtualBox network. Windows 7 can also be used to accomplish this task.

We can use a remote script to configure the server using the SSH protocol - in fact, to use this feature, we installed a "virtual machine". One of the most convenient tools for working with SSH on Windows is PuTTY. It must be downloaded from putty.org. But before that, you need to correctly install Ubuntu - there are some nuances associated with solving this problem. Let's consider them.

Features of OS installation in a virtual machine

At the beginning of the Ubuntu installation, the system will ask for the desired language settings... After entering them, the installation of additional components will begin. During the installation of the OS, the system may attempt to configure the network with DHCP, but this should be done only if this type of server is available on the network. If they are not there, then the user will be prompted to set the appropriate settings manually. But at the current stage of the installation it is not necessary to do this - you can skip this step.

Among the options that are important to us is the computer name. It might sound something like this: computer227.computer227network.com. This, of course, is not an address on the Internet, but just the necessary network identifier for the PC. Next, you need to configure Accounts user. It should be borne in mind that the word admin cannot be used as a nickname - this is the specifics of the Ubuntu OS (it is reserved in the system). You can choose an option like userhost, for example. Password - any that will be convenient for the owner of the PC.

The next step in installing Ubuntu is setting up the time and time zones. It is desirable to indicate real ones.

After setting up the hard drive, the download of the main files will start. After its completion, the system will offer to configure the APT packages - but this is important only if the user wants to install a proxy server. Let's agree that we will not use it on the network, so you can skip this configuration step.

Next, the system will ask if it is necessary to install. Many IT specialists prefer not to carry out this procedure, since in this case it is possible to completely control the processes taking place in the OS. Then, in the interface window, you need to mark OpenSSH as the type of software used.

In the further process of installing Ubuntu, the system will ask whether to install the GRUB bootloader in the appropriate area of ​​the disk. After the OS is fully installed, you need to restart the PC.

Basic network options

The next step in working with VM VirtualBox is setting up the network using the Ubuntu OS interfaces. You need to enter the operating system using the login and password that we determined during the installation.

The next necessary action is to obtain access rights at the ROOT level, that is, the superuser. The corresponding option must be activated.

This can be done by entering the command: sudo su. Another option is to enter sudo passwd root with a password at the command line. Actually, these are the main settings at this stage. You can download PuTTY and manage your Ubuntu server through a virtual machine.

The nuances of network settings

What are the nuances of working with Oracle VirtualBox? Network configuration may require adjustments to a number of other options. Which ones?

For example, you may need to configure the server in terms of establishing a permanent IP address on it. To do this, you need to make the appropriate changes to / etc / network / interfaces. This is done through the following command: nano / etc / network / interfaces. After that, you can restart the network with the following command: /etc/init.d/networking restart.

Then you need to make adjustments to / etc / hosts using the appropriate nano command. The following settings must be present in the file structure:

127.0.0.1 - for localhost;

192.168.0.1 (if the IP address of the computer on the local network differs from the specified one, write the correct one) for the server address specified above, that is, computer277.computer277network.com computer277.

Next, you need to synchronize the clock running in the system with a time server on the Internet. To do this, enter apt-get install ntp update into the command line. This completes the configuration. Then you can fully use Oracle VM VirtualBox. simple enough. The subsequent use of Ubuntu with the help of a "virtual machine" implies the possibility of using the widest set of functions of this server OS.

Universal Tool: Works on Windows XP

Is the virtual machine running from Oracle in a relatively outdated versions Windows like XP? Yes, it is quite. In accordance with the considered algorithm, it is possible to configure other operating systems using VirtualBox. Customization Windows networking XP, of course, will be implemented in slightly different ways. In particular, command line as in Ubuntu, it will not be involved in this procedure.

However, Windows XP has controls for a local network that are quite understandable even for an unprepared user, and working with them should not be accompanied by tangible difficulties and failures.

Of course, in addition to Ubuntu, other operating systems from the Linux line are compatible with the "virtual machine" algorithms. Among those that are great for use with VirtualBox is CentOS. Network configuration in this Linux distribution will be carried out on the basis of algorithms, in general, similar to those that we used when working with Ubuntu.