VirtualBox

source: vbox/trunk/doc/manual/en_US/user_Networking.xml@ 48389

Last change on this file since 48389 was 48389, checked in by vboxsync, 11 years ago

doc/manual: cosmetics

File size: 46.1 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
4<chapter id="networkingdetails">
5 <title>Virtual networking</title>
6
7 <para>As briefly mentioned in <xref linkend="settings-network" />,
8 VirtualBox provides up to eight virtual PCI Ethernet cards for each virtual
9 machine. For each such card, you can individually select<orderedlist>
10 <listitem>
11 <para>the hardware that will be virtualized as well as</para>
12 </listitem>
13
14 <listitem>
15 <para>the virtualization mode that the virtual card will be operating
16 in with respect to your physical networking hardware on the
17 host.</para>
18 </listitem>
19 </orderedlist></para>
20
21 <para>Four of the network cards can be configured in the "Network" section
22 of the settings dialog in the graphical user interface of VirtualBox. You
23 can configure all eight network cards on the command line via VBoxManage
24 modifyvm; see <xref linkend="vboxmanage-modifyvm" />.</para>
25
26 <para>This chapter explains the various networking settings in more
27 detail.</para>
28
29 <sect1 id="nichardware">
30 <title>Virtual networking hardware</title>
31
32 <para>For each card, you can individually select what kind of
33 <emphasis>hardware</emphasis> will be presented to the virtual machine.
34 VirtualBox can virtualize the following six types of networking
35 hardware:<itemizedlist>
36 <listitem>
37 <para>AMD PCNet PCI II (Am79C970A);</para>
38 </listitem>
39
40 <listitem>
41 <para>AMD PCNet FAST III (Am79C973, the default);</para>
42 </listitem>
43
44 <listitem>
45 <para>Intel PRO/1000 MT Desktop (82540EM);</para>
46 </listitem>
47
48 <listitem>
49 <para>Intel PRO/1000 T Server (82543GC);</para>
50 </listitem>
51
52 <listitem>
53 <para>Intel PRO/1000 MT Server (82545EM);</para>
54 </listitem>
55
56 <listitem>
57 <para>Paravirtualized network adapter (virtio-net).</para>
58 </listitem>
59 </itemizedlist></para>
60
61 <para>The PCNet FAST III is the default because it is supported by nearly
62 all operating systems out of the box, as well as the GNU GRUB boot
63 manager. As an exception, the Intel PRO/1000 family adapters are chosen
64 for some guest operating system types that no longer ship with drivers for
65 the PCNet card, such as Windows Vista.</para>
66
67 <para>The Intel PRO/1000 MT Desktop type works with Windows Vista and
68 later versions. The T Server variant of the Intel PRO/1000 card is
69 recognized by Windows XP guests without additional driver installation.
70 The MT Server variant facilitates OVF imports from other platforms.</para>
71
72 <para>The <emphasis role="bold">"Paravirtualized network adapter
73 (virtio-net)"</emphasis> is special. If you select this, then VirtualBox
74 does <emphasis>not</emphasis> virtualize common networking hardware (that
75 is supported by common guest operating systems out of the box). Instead,
76 VirtualBox then expects a special software interface for virtualized
77 environments to be provided by the guest, thus avoiding the complexity of
78 emulating networking hardware and improving network performance. Starting
79 with version 3.1, VirtualBox provides support for the industry-standard
80 "virtio" networking drivers, which are part of the open-source KVM
81 project.</para>
82
83 <para>The "virtio" networking drivers are available for the following
84 guest operating systems:</para>
85
86 <para><itemizedlist>
87 <listitem>
88 <para>Linux kernels version 2.6.25 or later can be configured to
89 provide virtio support; some distributions also back-ported virtio
90 to older kernels.</para>
91 </listitem>
92
93 <listitem>
94 <para>For Windows 2000, XP and Vista, virtio drivers can be
95 downloaded and installed from the KVM project web page.<footnote>
96 <para><ulink
97 url="http://www.linux-kvm.org/page/WindowsGuestDrivers">http://www.linux-kvm.org/page/WindowsGuestDrivers</ulink>.</para>
98 </footnote></para>
99 </listitem>
100 </itemizedlist></para>
101
102 <para>VirtualBox also has limited support for so-called <emphasis
103 role="bold">jumbo frames</emphasis>, i.e. networking packets with more
104 than 1500 bytes of data, provided that you use the Intel card
105 virtualization and bridged networking. In other words, jumbo frames are
106 not supported with the AMD networking devices; in those cases, jumbo
107 packets will silently be dropped for both the transmit and the receive
108 direction. Guest operating systems trying to use this feature will observe
109 this as a packet loss, which may lead to unexpected application behavior
110 in the guest. This does not cause problems with guest operating systems in
111 their default configuration, as jumbo frames need to be explicitly
112 enabled.</para>
113 </sect1>
114
115 <sect1 id="networkingmodes">
116 <title>Introduction to networking modes</title>
117
118 <para>Each of the eight networking adapters can be separately configured
119 to operate in one of the following modes:<glosslist>
120 <glossentry>
121 <glossterm>Not attached</glossterm>
122
123 <glossdef>
124 <para>In this mode, VirtualBox reports to the guest that a network
125 card is present, but that there is no connection -- as if no
126 Ethernet cable was plugged into the card. This way it is possible
127 to "pull" the virtual Ethernet cable and disrupt the connection,
128 which can be useful to inform a guest operating system that no
129 network connection is available and enforce a
130 reconfiguration.</para>
131 </glossdef>
132 </glossentry>
133
134 <glossentry>
135 <glossterm>Network Address Translation (NAT)</glossterm>
136
137 <glossdef>
138 <para>If all you want is to browse the Web, download files and
139 view e-mail inside the guest, then this default mode should be
140 sufficient for you, and you can safely skip the rest of this
141 section. Please note that there are certain limitations when using
142 Windows file sharing (see <xref linkend="nat-limitations" /> for
143 details).</para>
144 </glossdef>
145 </glossentry>
146
147 <glossentry>
148 <glossterm>Bridged networking</glossterm>
149
150 <glossdef>
151 <para>This is for more advanced networking needs such as network
152 simulations and running servers in a guest. When enabled,
153 VirtualBox connects to one of your installed network cards and
154 exchanges network packets directly, circumventing your host
155 operating system's network stack.</para>
156 </glossdef>
157 </glossentry>
158
159 <glossentry>
160 <glossterm>Internal networking</glossterm>
161
162 <glossdef>
163 <para>This can be used to create a different kind of
164 software-based network which is visible to selected virtual
165 machines, but not to applications running on the host or to the
166 outside world.</para>
167 </glossdef>
168 </glossentry>
169
170 <glossentry>
171 <glossterm>Host-only networking</glossterm>
172
173 <glossdef>
174 <para>This can be used to create a network containing the host and
175 a set of virtual machines, without the need for the host's
176 physical network interface. Instead, a virtual network interface
177 (similar to a loopback interface) is created on the host,
178 providing connectivity among virtual machines and the host.</para>
179 </glossdef>
180 </glossentry>
181
182 <glossentry>
183 <glossterm>Generic networking</glossterm>
184
185 <glossdef>
186 <para>Rarely used modes share the same generic network interface,
187 by allowing the user to select a driver which can be included with
188 VirtualBox or be distributed in an extension pack.</para>
189
190 <para>At the moment there are potentially two available
191 sub-modes:</para>
192
193 <para><glosslist>
194 <glossentry>
195 <glossterm>UDP Tunnel</glossterm>
196
197 <glossdef>
198 <para>This can be used to interconnect virtual machines
199 running on different hosts directly, easily and
200 transparently, over existing network
201 infrastructure.</para>
202 </glossdef>
203 </glossentry>
204
205 <glossentry>
206 <glossterm>VDE (Virtual Distributed Ethernet)
207 networking</glossterm>
208
209 <glossdef>
210 <para>This option can be used to connect to a Virtual
211 Distributed Ethernet switch on a Linux or a FreeBSD host.
212 At the moment this needs compiling VirtualBox from
213 sources, as the Oracle packages do not include it.</para>
214 </glossdef>
215 </glossentry>
216 </glosslist></para>
217 </glossdef>
218 </glossentry>
219 </glosslist></para>
220
221 <para>The following sections describe the available network modes in more
222 detail.</para>
223 </sect1>
224
225 <sect1 id="network_nat">
226 <title>Network Address Translation (NAT)</title>
227
228 <para>Network Address Translation (NAT) is the simplest way of accessing
229 an external network from a virtual machine. Usually, it does not require
230 any configuration on the host network and guest system. For this reason,
231 it is the default networking mode in VirtualBox.</para>
232
233 <para>A virtual machine with NAT enabled acts much like a real computer
234 that connects to the Internet through a router. The "router", in this
235 case, is the VirtualBox networking engine, which maps traffic from and to
236 the virtual machine transparently. In VirtualBox this router is placed
237 between each virtual machine and the host. This separation maximizes
238 security since by default virtual machines cannot talk to each
239 other.</para>
240
241 <para>The disadvantage of NAT mode is that, much like a private network
242 behind a router, the virtual machine is invisible and unreachable from the
243 outside internet; you cannot run a server this way unless you set up port
244 forwarding (described below).</para>
245
246 <para>The network frames sent out by the guest operating system are
247 received by VirtualBox's NAT engine, which extracts the TCP/IP data and
248 resends it using the host operating system. To an application on the host,
249 or to another computer on the same network as the host, it looks like the
250 data was sent by the VirtualBox application on the host, using an IP
251 address belonging to the host. VirtualBox listens for replies to the
252 packages sent, and repacks and resends them to the guest machine on its
253 private network.</para>
254
255 <para>The virtual machine receives its network address and configuration
256 on the private network from a DHCP server integrated into VirtualBox. The
257 IP address thus assigned to the virtual machine is usually on a completely
258 different network than the host. As more than one card of a virtual
259 machine can be set up to use NAT, the first card is connected to the
260 private network 10.0.2.0, the second card to the network 10.0.3.0 and so
261 on. If you need to change the guest-assigned IP range for some reason,
262 please refer to <xref linkend="changenat" />.</para>
263
264 <sect2 id="natforward">
265 <title>Configuring port forwarding with NAT</title>
266
267 <para>As the virtual machine is connected to a private network internal
268 to VirtualBox and invisible to the host, network services on the guest
269 are not accessible to the host machine or to other computers on the same
270 network. However, like a physical router, VirtualBox can make selected
271 services available to the world outside the guest through <emphasis
272 role="bold">port forwarding.</emphasis> This means that VirtualBox
273 listens to certain ports on the host and resends all packets which
274 arrive there to the guest, on the same or a different port.</para>
275
276 <para>To an application on the host or other physical (or virtual)
277 machines on the network, it looks as though the service being proxied is
278 actually running on the host. This also means that you cannot run the
279 same service on the same ports on the host. However, you still gain the
280 advantages of running the service in a virtual machine -- for example,
281 services on the host machine or on other virtual machines cannot be
282 compromised or crashed by a vulnerability or a bug in the service, and
283 the service can run in a different operating system than the host
284 system.</para>
285
286 <para>To configure Port Forwarding you can use the graphical Port
287 Forwarding editor which can be found in the Network Settings dialog
288 for Network Adaptors configured to use NAT. Here you can map host
289 ports to guest ports to allow network traffic to be routed to a
290 specific port in the guest.</para>
291
292 <para>Alternatively command line tool <computeroutput>VBoxManage</computeroutput> could be used;
293 for details, please refer to <xref linkend="vboxmanage-modifyvm" />.</para>
294
295 <para>You will need to know which ports on the guest the service uses
296 and to decide which ports to use on the host (often but not always you
297 will want to use the same ports on the guest and on the host). You can
298 use any ports on the host which are not already in use by a service. For
299 example, to set up incoming NAT connections to an
300 <computeroutput>ssh</computeroutput> server in the guest, use the
301 following command: <screen>VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"</screen>With
302 the above example, all TCP traffic arriving on port 2222 on any host
303 interface will be forwarded to port 22 in the guest. The protocol name
304 <computeroutput>tcp</computeroutput> is a mandatory attribute defining
305 which protocol should be used for forwarding
306 (<computeroutput>udp</computeroutput> could also be used). The name
307 <computeroutput>guestssh</computeroutput> is purely descriptive and will
308 be auto-generated if omitted. The number after
309 <computeroutput>--natpf</computeroutput> denotes the network card, like
310 in other parts of VBoxManage.</para>
311
312 <para>To remove this forwarding rule again, use the following command:
313 <screen>VBoxManage modifyvm "VM name" --natpf1 delete "guestssh"</screen></para>
314
315 <para>If for some reason the guest uses a static assigned IP address not
316 leased from the built-in DHCP server, it is required to specify the
317 guest IP when registering the forwarding rule: <screen>VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,10.0.2.19,22"</screen>This
318 example is identical to the previous one, except that the NAT engine is
319 being told that the guest can be found at the 10.0.2.19 address.</para>
320
321 <para>To forward <emphasis>all</emphasis> incoming traffic from a
322 specific host interface to the guest, specify the IP of that host
323 interface like this:<screen>VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,127.0.0.1,2222,,22"</screen>This
324 forwards all TCP traffic arriving on the localhost interface (127.0.0.1)
325 via port 2222 to port 22 in the guest.</para>
326
327 <para>It is possible to configure incoming NAT connections while the
328 VM is running, see <xref linkend="vboxmanage-controlvm"/>.</para>
329 </sect2>
330
331 <sect2 id="nat-tftp">
332 <title>PXE booting with NAT</title>
333
334 <para>PXE booting is now supported in NAT mode. The NAT DHCP server
335 provides a boot file name of the form
336 <computeroutput>vmname.pxe</computeroutput> if the directory
337 <computeroutput>TFTP</computeroutput> exists in the directory where the
338 user's <computeroutput>VirtualBox.xml</computeroutput> file is kept. It
339 is the responsibility of the user to provide
340 <computeroutput>vmname.pxe</computeroutput>.</para>
341 </sect2>
342
343 <sect2 id="nat-limitations">
344 <title>NAT limitations</title>
345
346 <para>There are four <emphasis role="bold">limitations</emphasis> of NAT
347 mode which users should be aware of:</para>
348
349 <glosslist>
350 <glossentry>
351 <glossterm>ICMP protocol limitations:</glossterm>
352
353 <glossdef>
354 <para>Some frequently used network debugging tools (e.g.
355 <computeroutput>ping</computeroutput> or tracerouting) rely on the
356 ICMP protocol for sending/receiving messages. While ICMP support
357 has been improved with VirtualBox 2.1
358 (<computeroutput>ping</computeroutput> should now work), some
359 other tools may not work reliably.</para>
360 </glossdef>
361 </glossentry>
362
363 <glossentry>
364 <glossterm>Receiving of UDP broadcasts is not reliable:</glossterm>
365
366 <glossdef>
367 <para>The guest does not reliably receive broadcasts, since, in
368 order to save resources, it only listens for a certain amount of
369 time after the guest has sent UDP data on a particular port. As a
370 consequence, NetBios name resolution based on broadcasts does not
371 always work (but WINS always works). As a workaround, you can use
372 the numeric IP of the desired server in the
373 <computeroutput>\\server\share</computeroutput> notation.</para>
374 </glossdef>
375 </glossentry>
376
377 <glossentry>
378 <glossterm>Protocols such as GRE are unsupported:</glossterm>
379
380 <glossdef>
381 <para>Protocols other than TCP and UDP are not supported. This
382 means some VPN products (e.g. PPTP from Microsoft) cannot be used.
383 There are other VPN products which use simply TCP and UDP.</para>
384 </glossdef>
385 </glossentry>
386
387 <glossentry>
388 <glossterm>Forwarding host ports &lt; 1024 impossible:</glossterm>
389
390 <glossdef>
391 <para>On Unix-based hosts (e.g. Linux, Solaris, Mac OS X) it is
392 not possible to bind to ports below 1024 from applications that
393 are not run by <computeroutput>root</computeroutput>. As a result,
394 if you try to configure such a port forwarding, the VM will refuse
395 to start.</para>
396 </glossdef>
397 </glossentry>
398 </glosslist>
399
400 <para>These limitations normally don't affect standard network use. But
401 the presence of NAT has also subtle effects that may interfere with
402 protocols that are normally working. One example is NFS, where the
403 server is often configured to refuse connections from non-privileged
404 ports (i.e. ports not below 1024).</para>
405 </sect2>
406 </sect1>
407
408 <sect1 id="network_nat_service">
409 <title>Network Address Translation Service (experimental)</title>
410
411 <para>The Network Address Translation (NAT) service works in a similar way
412 to a home router, grouping the systems using it into a network and
413 preventing systems outside of this network from directly accessing systems
414 inside it, but letting systems inside communicate with each other and with
415 systems outside using TCP and UDP over IPv4 and IPv6.</para>
416
417 <para>A NAT service is attached to an internal network. Virtual machines
418 which are to make use of it should be attached to that internal network.
419 The name of internal network is chosen when the NAT service is created and
420 the internal network will be created if it does not already exist. An
421 example command to create a NAT network is:
422 </para>
423 <para><screen>VBoxManage natnetwork add -t nat-int-network -n "192.168.15.0/24" -e</screen></para>
424 <para>
425 Here, "nat-int-network" is the name of the internal network to be used and
426 "192.168.15.0/24" is the network address and mask of the NAT service
427 interface. By default in this static configuration the gateway will be
428 assigned the address 192.168.15.1 (the address following the interface
429 address), though this is subject to change. To attach a DHCP server to the
430 internal network, we modify the example as follows:</para>
431 <para><screen>VBoxManage natnetwork add -t nat-int-network -n "192.168.15.0/24" -e -h on</screen></para>
432 <para> or to add a DHCP server to the network after creation:</para>
433 <para><screen>VBoxManage natnetwork modify -t nat-int-network -h on</screen></para>
434 <para>To disable it again, use:</para>
435 <para><screen>VBoxManage natnetwork modify -t nat-int-network -h off</screen></para>
436 <para>DHCP server provides list of registered nameservers, but doesn't map
437 servers from 127/8 network.</para>
438 <para>To start the NAT service, use the following command:</para>
439 <para><screen>VBoxManage natnetwork start -t nat-int-network</screen></para>
440 <para>If the network has a DHCP server attached then it will start together
441 with the NAT network service.</para>
442 <para><screen>VBoxManage natnetwork stop -t nat-int-network</screen> stops
443 the NAT network service, together with DHCP server if any.</para>
444 <para>To delete the NAT network service use:</para>
445 <para><screen>VBoxManage natnetwork remove -t nat-int-network</screen></para>
446 <para>This command does not remove the DHCP server if one is enabled on the
447 internal network.</para>
448 <para>Port-forwarding is supported (using the "-p" switch for IPv4 and "-P"
449 for IPv6):</para>
450 <para><screen>VBoxManage natnetwork modify -t nat-int-network -p "ssh:tcp:[]:10022:[192.168.15.15]:22"</screen></para>
451 <para>This adds a port-forwarding rule from the host's TCP 10022 port to
452 the port 22 on the guest with IP address 192.168.15.15. To delete the rule,
453 use:</para>
454 <para><screen>VBoxManage natnetwork modify -t nat-int-network -p delete ssh</screen></para>
455 <para>It's possible to bind NAT service to specified interface:</para>
456 <screen>VBoxManage setextradata global "NAT/win-nat-test-0/SourceIp4" 192.168.1.185</screen>
457 <para>To see the list of registered NAT networks, use:</para>
458 <para><screen>VBoxManage list natnetworks</screen></para>
459 </sect1>
460
461 <sect1 id="network_bridged">
462 <title>Bridged networking</title>
463
464 <para>With bridged networking, VirtualBox uses a device driver on your
465 <emphasis>host</emphasis> system that filters data from your physical
466 network adapter. This driver is therefore called a "net filter" driver.
467 This allows VirtualBox to intercept data from the physical network and
468 inject data into it, effectively creating a new network interface in
469 software. When a guest is using such a new software interface, it looks to
470 the host system as though the guest were physically connected to the
471 interface using a network cable: the host can send data to the guest
472 through that interface and receive data from it. This means that you can
473 set up routing or bridging between the guest and the rest of your
474 network.</para>
475
476 <para>For this to work, VirtualBox needs a device driver on your host
477 system. The way bridged networking works has been completely rewritten
478 with VirtualBox 2.0 and 2.1, depending on the host operating system. From
479 the user perspective, the main difference is that complex configuration is
480 no longer necessary on any of the supported host operating
481 systems.<footnote>
482 <para>For Mac OS X and Solaris hosts, net filter drivers were already
483 added in VirtualBox 2.0 (as initial support for Host Interface
484 Networking on these platforms). With VirtualBox 2.1, net filter
485 drivers were also added for the Windows and Linux hosts, replacing the
486 mechanisms previously present in VirtualBox for those platforms;
487 especially on Linux, the earlier method required creating TAP
488 interfaces and bridges, which was complex and varied from one
489 distribution to the next. None of this is necessary anymore. Bridged
490 network was formerly called "Host Interface Networking" and has been
491 renamed with version 2.2 without any change in functionality.</para>
492 </footnote></para>
493
494 <para><note>
495 <para>Even though TAP is no longer necessary on Linux with bridged
496 networking, you <emphasis>can</emphasis> still use TAP interfaces for
497 certain advanced setups, since you can connect a VM to any host
498 interface -- which could also be a TAP interface.</para>
499 </note>To enable bridged networking, all you need to do is to open the
500 Settings dialog of a virtual machine, go to the "Network" page and select
501 "Bridged network" in the drop down list for the "Attached to" field.
502 Finally, select desired host interface from the list at the bottom of the
503 page, which contains the physical network interfaces of your systems. On a
504 typical MacBook, for example, this will allow you to select between "en1:
505 AirPort" (which is the wireless interface) and "en0: Ethernet", which
506 represents the interface with a network cable.</para>
507
508 <note><para>Bridging to a wireless interface is done differently from
509 bridging to a wired interface, because most wireless adapters do not
510 support promiscuous mode. All traffic has to use the MAC address of the
511 host's wireless adapter, and therefore VirtualBox needs to replace the
512 source MAC address in the Ethernet header of an outgoing packet to make
513 sure the reply will be sent to the host interface. When VirtualBox sees
514 an incoming packet with a destination IP address that belongs to one of
515 the virtual machine adapters it replaces the destination MAC address in
516 the Ethernet header with the VM adapter's MAC address and passes it on.
517 VirtualBox examines ARP and DHCP packets in order to learn the IP
518 addresses of virtual machines.</para></note>
519
520 <para>Depending on your host operating system, the following limitations
521 should be kept in mind:<itemizedlist>
522 <listitem>
523 <para>On <emphasis role="bold">Macintosh</emphasis> hosts,
524 functionality is limited when using AirPort (the Mac's wireless
525 networking) for bridged networking. Currently, VirtualBox supports
526 only IPv4 over AirPort. For other protocols such as IPv6 and IPX,
527 you must choose a wired interface.</para>
528 </listitem>
529
530 <listitem>
531 <para>On <emphasis role="bold">Linux</emphasis> hosts, functionality
532 is limited when using wireless interfaces for bridged networking.
533 Currently, VirtualBox supports only IPv4 over wireless. For other
534 protocols such as IPv6 and IPX, you must choose a wired
535 interface.</para>
536
537 <para>Also, setting the MTU to less than 1500 bytes on wired
538 interfaces provided by the sky2 driver on the Marvell Yukon II EC
539 Ultra Ethernet NIC is known to cause packet losses under certain
540 conditions.</para>
541
542 <para>Some adapters strip VLAN tags in hardware. This does not allow
543 to use VLAN trunking between VM and the external network with
544 pre-2.6.27 Linux kernels nor with host operating systems other than
545 Linux.</para>
546 </listitem>
547
548 <listitem>
549 <para>On <emphasis role="bold">Solaris</emphasis> hosts, there is no
550 support for using wireless interfaces. Filtering guest traffic using
551 IPFilter is also not completely supported due to technical
552 restrictions of the Solaris networking subsystem. These issues would
553 be addressed in a future release of Solaris 11.</para>
554
555 <para>Starting with VirtualBox 4.1, on Solaris 11 hosts (build 159
556 and above), it is possible to use Solaris' Crossbow Virtual Network
557 Interfaces (VNICs) directly with VirtualBox without any additional
558 configuration other than each VNIC must be exclusive for every guest
559 network interface. With VirtualBox 2.0.4 and above, VNICs can be
560 used but with the following caveats:</para>
561
562 <itemizedlist>
563 <listitem>
564 <para>A VNIC cannot be shared between multiple guest network
565 interfaces, i.e. each guest network interface must have its own,
566 exclusive VNIC.</para>
567 </listitem>
568
569 <listitem>
570 <para>The VNIC and the guest network interface that uses the
571 VNIC must be assigned identical MAC addresses.</para>
572 </listitem>
573 </itemizedlist>
574
575 <para>When using VLAN interfaces with VirtualBox, they must be named
576 according to the PPA-hack naming scheme (e.g. "e1000g513001"), as
577 otherwise the guest may receive packets in an unexpected
578 format.</para>
579 </listitem>
580 </itemizedlist></para>
581 </sect1>
582
583 <sect1 id="network_internal">
584 <title>Internal networking</title>
585
586 <para>Internal Networking is similar to bridged networking in that the VM
587 can directly communicate with the outside world. However, the "outside
588 world" is limited to other VMs on the same host which connect to the same
589 internal network.</para>
590
591 <para>Even though technically, everything that can be done using internal
592 networking can also be done using bridged networking, there are security
593 advantages with internal networking. In bridged networking mode, all
594 traffic goes through a physical interface of the host system. It is
595 therefore possible to attach a packet sniffer (such as Wireshark) to the
596 host interface and log all traffic that goes over it. If, for any reason,
597 you prefer two or more VMs on the same machine to communicate privately,
598 hiding their data from both the host system and the user, bridged
599 networking therefore is not an option.</para>
600
601 <para>Internal networks are created automatically as needed, i.e. there is
602 no central configuration. Every internal network is identified simply by
603 its name. Once there is more than one active virtual network card with the
604 same internal network ID, the VirtualBox support driver will automatically
605 "wire" the cards and act as a network switch. The VirtualBox support
606 driver implements a complete Ethernet switch and supports both
607 broadcast/multicast frames and promiscuous mode.</para>
608
609 <para>In order to attach a VM's network card to an internal network, set
610 its networking mode to "internal networking". There are two ways to
611 accomplish this:</para>
612
613 <para><itemizedlist>
614 <listitem>
615 <para>You can use a VM's "Settings" dialog in the VirtualBox
616 graphical user interface. In the "Networking" category of the
617 settings dialog, select "Internal Networking" from the drop-down
618 list of networking modes. Now select the name of an existing
619 internal network from the drop-down below or enter a new name into
620 the entry field.</para>
621 </listitem>
622
623 <listitem>
624 <para>You can use <screen>VBoxManage modifyvm "VM name" --nic&lt;x&gt; intnet</screen>
625 Optionally, you can specify a network name with the command <screen>VBoxManage modifyvm "VM name" --intnet&lt;x&gt; "network name"</screen>
626 If you do not specify a network name, the network card will be
627 attached to the network <computeroutput>intnet</computeroutput> by
628 default.</para>
629 </listitem>
630 </itemizedlist></para>
631
632 <para>Unless you configure the (virtual) network cards in the guest
633 operating systems that are participating in the internal network to use
634 static IP addresses, you may want to use the DHCP server that is built
635 into VirtualBox to manage IP addresses for the internal network. Please
636 see <xref linkend="vboxmanage-dhcpserver" /> for details.</para>
637
638 <para>As a security measure, the Linux implementation of internal
639 networking only allows VMs running under the same user ID to establish an
640 internal network.</para>
641 </sect1>
642
643 <sect1 id="network_hostonly">
644 <title>Host-only networking</title>
645
646 <para>Host-only networking is another networking mode that was added with
647 version 2.2 of VirtualBox. It can be thought of as a hybrid between the
648 bridged and internal networking modes: as with bridged networking, the
649 virtual machines can talk to each other and the host as if they were
650 connected through a physical Ethernet switch. Similarly, as with internal
651 networking however, a physical networking interface need not be present,
652 and the virtual machines cannot talk to the world outside the host since
653 they are not connected to a physical networking interface.</para>
654
655 <para>Instead, when host-only networking is used, VirtualBox creates a new
656 software interface on the host which then appears next to your existing
657 network interfaces. In other words, whereas with bridged networking an
658 existing physical interface is used to attach virtual machines to, with
659 host-only networking a new "loopback" interface is created on the host.
660 And whereas with internal networking, the traffic between the virtual
661 machines cannot be seen, the traffic on the "loopback" interface on the
662 host can be intercepted.</para>
663
664 <para>Host-only networking is particularly useful for preconfigured
665 virtual appliances, where multiple virtual machines are shipped together
666 and designed to cooperate. For example, one virtual machine may contain a
667 web server and a second one a database, and since they are intended to
668 talk to each other, the appliance can instruct VirtualBox to set up a
669 host-only network for the two. A second (bridged) network would then
670 connect the web server to the outside world to serve data to, but the
671 outside world cannot connect to the database.</para>
672
673 <para>To change a virtual machine's virtual network interface to "host
674 only" mode:<itemizedlist>
675 <listitem>
676 <para>either go to the "Network" page in the virtual machine's
677 settings notebook in the graphical user interface and select
678 "Host-only networking", or</para>
679 </listitem>
680
681 <listitem>
682 <para>on the command line, type <computeroutput>VBoxManage modifyvm
683 "VM name" --nic&lt;x&gt; hostonly</computeroutput>; see <xref
684 linkend="vboxmanage-modifyvm" /> for details.</para>
685 </listitem>
686 </itemizedlist></para>
687
688 <para>For host-only networking, like with internal networking, you may
689 find the DHCP server useful that is built into VirtualBox. This can be
690 enabled to then manage the IP addresses in the host-only network since
691 otherwise you would need to configure all IP addresses
692 statically.<itemizedlist>
693 <listitem>
694 <para>In the VirtualBox graphical user interface, you can configure
695 all these items in the global settings via "File" -&gt; "Settings"
696 -&gt; "Network", which lists all host-only networks which are
697 presently in use. Click on the network name and then on the "Edit"
698 button to the right, and you can modify the adapter and DHCP
699 settings.</para>
700 </listitem>
701
702 <listitem>
703 <para>Alternatively, you can use <computeroutput>VBoxManage
704 dhcpserver</computeroutput> on the command line; please see <xref
705 linkend="vboxmanage-dhcpserver" /> for details.</para>
706 </listitem>
707 </itemizedlist></para>
708 <para><note>On Linux and Mac OS X hosts the number of host-only interfaces is
709 limited to 128. There is no such limit for Solaris and Windows hosts.</note></para>
710 </sect1>
711
712 <sect1 id="network_udp_tunnel">
713 <title>UDP Tunnel networking</title>
714
715 <para>This networking mode allows to interconnect virtual machines running
716 on different hosts.</para>
717
718 <para>Technically this is done by encapsulating Ethernet frames sent or
719 received by the guest network card into UDP/IP datagrams, and sending them
720 over any network available to the host.</para>
721
722 <para>UDP Tunnel mode has three parameters:<glosslist>
723 <glossentry>
724 <glossterm>Source UDP port</glossterm>
725
726 <glossdef>
727 <para>The port on which the host listens. Datagrams arriving on
728 this port from any source address will be forwarded to the
729 receiving part of the guest network card.</para>
730 </glossdef>
731 </glossentry>
732
733 <glossentry>
734 <glossterm>Destination address</glossterm>
735
736 <glossdef>
737 <para>IP address of the target host of the transmitted
738 data.</para>
739 </glossdef>
740 </glossentry>
741
742 <glossentry>
743 <glossterm>Destination UDP port</glossterm>
744
745 <glossdef>
746 <para>Port number to which the transmitted data is sent.</para>
747 </glossdef>
748 </glossentry>
749 </glosslist></para>
750
751 <para>When interconnecting two virtual machines on two different hosts,
752 their IP addresses must be swapped. On single host, source and destination
753 UDP ports must be swapped.</para>
754
755 <para>In the following example host 1 uses the IP address 10.0.0.1 and
756 host 2 uses IP address 10.0.0.2. Configuration via command-line:<screen> VBoxManage modifyvm "VM 01 on host 1" --nic&lt;x&gt; generic
757 VBoxManage modifyvm "VM 01 on host 1" --nicgenericdrv&lt;x&gt; UDPTunnel
758 VBoxManage modifyvm "VM 01 on host 1" --nicproperty&lt;x&gt; dest=10.0.0.2
759 VBoxManage modifyvm "VM 01 on host 1" --nicproperty&lt;x&gt; sport=10001
760 VBoxManage modifyvm "VM 01 on host 1" --nicproperty&lt;x&gt; dport=10002</screen>
761 and <screen> VBoxManage modifyvm "VM 02 on host 2" --nic&lt;y&gt; generic
762 VBoxManage modifyvm "VM 02 on host 2" --nicgenericdrv&lt;y&gt; UDPTunnel
763 VBoxManage modifyvm "VM 02 on host 2" --nicproperty&lt;y&gt; dest=10.0.0.1
764 VBoxManage modifyvm "VM 02 on host 2" --nicproperty&lt;y&gt; sport=10002
765 VBoxManage modifyvm "VM 02 on host 2" --nicproperty&lt;y&gt; dport=10001</screen></para>
766
767 <para>Of course, you can always interconnect two virtual machines on the
768 same host, by setting the destination address parameter to 127.0.0.1 on
769 both. It will act similarly to "Internal network" in this case, however
770 the host can see the network traffic which it could not in the normal
771 Internal network case.</para>
772
773 <para><note>
774 On Unix-based hosts (e.g. Linux, Solaris, Mac OS X) it is not possible
775 to bind to ports below 1024 from applications that are not run by
776 <computeroutput>root</computeroutput>. As a result, if you try to
777 configure such a source UDP port, the VM will refuse to start.
778 </note></para>
779 </sect1>
780
781 <sect1 id="network_vde">
782 <title>VDE networking</title>
783
784 <para>Virtual Distributed Ethernet (VDE<footnote>
785 <para>VDE is a project developed by Renzo Davoli, Associate Professor
786 at the University of Bologna, Italy.</para>
787 </footnote>) is a flexible, virtual network infrastructure system,
788 spanning across multiple hosts in a secure way. It allows for L2/L3
789 switching, including spanning-tree protocol, VLANs, and WAN emulation. It
790 is an optional part of VirtualBox which is only included in the source
791 code.</para>
792
793 <para>The basic building blocks of the infrastructure are VDE switches,
794 VDE plugs and VDE wires which inter-connect the switches.</para>
795
796 <para>The VirtualBox VDE driver has one parameter:<glosslist>
797 <glossentry>
798 <glossterm>VDE network</glossterm>
799
800 <glossdef>
801 <para>The name of the VDE network switch socket to which the VM
802 will be connected.</para>
803 </glossdef>
804 </glossentry>
805 </glosslist></para>
806
807 <para>The following basic example shows how to connect a virtual machine
808 to a VDE switch:</para>
809
810 <para><orderedlist>
811 <listitem>
812 <para>Create a VDE switch: <screen>vde_switch -s /tmp/switch1</screen></para>
813 </listitem>
814
815 <listitem>
816 <para>Configuration via command-line: <screen>VBoxManage modifyvm "VM name" --nic&lt;x&gt; generic</screen>
817 <screen>VBoxManage modifyvm "VM name" --nicgenericdrv&lt;x&gt; VDE</screen>
818 To connect to automatically allocated switch port, use: <screen>VBoxManage modifyvm "VM name" --nicproperty&lt;x&gt; network=/tmp/switch1</screen>
819 To connect to specific switch port &lt;n&gt;, use: <screen>VBoxManage modifyvm "VM name" --nicproperty&lt;x&gt; network=/tmp/switch1[&lt;n&gt;]</screen>
820 The latter option can be useful for VLANs.</para>
821 </listitem>
822
823 <listitem>
824 <para>Optionally map between VDE switch port and VLAN: (from switch
825 CLI) <screen>vde$ vlan/create &lt;VLAN&gt;</screen> <screen>vde$ port/setvlan &lt;port&gt; &lt;VLAN&gt;</screen></para>
826 </listitem>
827 </orderedlist></para>
828
829 <para>VDE is available on Linux and FreeBSD hosts only. It is only
830 available if the VDE software and the VDE plugin library from the
831 VirtualSquare project are installed on the host system<footnote>
832 <para>For Linux hosts, the shared library libvdeplug.so must be
833 available in the search path for shared libraries</para>
834 </footnote>. For more information on setting up VDE networks, please see
835 the documentation accompanying the software.<footnote>
836 <para><ulink
837 url="http://wiki.virtualsquare.org/wiki/index.php/VDE_Basic_Networking">http://wiki.virtualsquare.org/wiki/index.php/VDE_Basic_Networking</ulink>.</para>
838 </footnote></para>
839 </sect1>
840
841 <sect1 id="network_bandwidth_limit">
842 <title>Limiting bandwidth for network I/O</title>
843
844 <para>Starting with version 4.2, VirtualBox allows for limiting the
845 maximum bandwidth used for network transmission. Several network adapters
846 of one VM may share limits through bandwidth groups. It is possible
847 to have more than one such limit.</para>
848 <note><para>VirtualBox shapes VM traffic only in the transmit direction,
849 delaying the packets being sent by virtual machines. It does not limit
850 the traffic being received by virtual machines.</para>
851 </note>
852
853 <para>Limits are configured through
854 <computeroutput>VBoxManage</computeroutput>. The example below creates a
855 bandwidth group named "Limit", sets the limit to 20 Mbit/s and assigns the
856 group to the first and second adapters of the VM:<screen>VBoxManage bandwidthctl "VM name" add Limit --type network --limit 20m
857VBoxManage modifyvm "VM name" --nicbandwidthgroup1 Limit
858VBoxManage modifyvm "VM name" --nicbandwidthgroup2 Limit</screen></para>
859
860 <para>All adapters in a group share the bandwidth limit, meaning that in the
861 example above the bandwidth of both adapters combined can never exceed 20
862 Mbit/s. However, if one adapter doesn't require bandwidth the other can use the
863 remaining bandwidth of its group.</para>
864
865 <para>The limits for each group can be changed while the VM is running,
866 with changes being picked up immediately. The example below changes the
867 limit for the group created in the example above to 100 Kbit/s:<screen>VBoxManage bandwidthctl "VM name" set Limit --limit 100k</screen></para>
868
869 <para>To completely disable shaping for the first adapter of VM use the
870 following command:
871 <screen>VBoxManage modifyvm "VM name" --nicbandwidthgroup1 none</screen></para>
872
873 <para>It is also possible to disable shaping for all adapters assigned to a
874 bandwidth group while VM is running, by specifying the zero limit for the
875 group. For example, for the bandwidth group named "Limit" use:
876 <screen>VBoxManage bandwidthctl "VM name" set Limit --limit 0</screen></para>
877 </sect1>
878 <sect1 id="network_performance">
879 <title>Improving network performance</title>
880
881 <para>VirtualBox provides a variety of virtual network adapters that can be
882 "attached" to the host's network in a number of ways. Depending on which
883 types of adapters and attachments are used the network performance will
884 be different. Performance-wise the <emphasis>virtio</emphasis> network
885 adapter is preferable over <emphasis>Intel PRO/1000</emphasis> emulated
886 adapters, which are preferred over <emphasis>PCNet</emphasis> family of
887 adapters. Both <emphasis>virtio</emphasis> and <emphasis>Intel PRO/1000
888 </emphasis> adapters enjoy the benefit of segmentation and checksum
889 offloading. Segmentation offloading is essential for high performance as
890 it allows for less context switches, dramatically increasing the sizes
891 of packets that cross VM/host boundary.</para>
892 <note><para>Neither <emphasis>virtio</emphasis> nor <emphasis>Intel PRO/1000
893 </emphasis> drivers for Windows XP support segmentation
894 offloading. Therefore Windows XP guests never reach the same
895 transmission rates as other guest types. Refer to MS Knowledge base
896 article 842264 for additional information.</para>
897 </note>
898 <para>Three attachment types: <emphasis>internal</emphasis>,
899 <emphasis>bridged</emphasis> and <emphasis>host-only</emphasis>, have
900 nearly identical performance, the <emphasis>internal</emphasis> type
901 being a little bit faster and using less CPU cycles as the packets never
902 reach the host's network stack. The <emphasis>NAT</emphasis> attachment
903 is the slowest (and safest) of all attachment types as it provides
904 network address translation. The generic driver attachment is special and
905 cannot be considered as an alternative to other attachment types.</para>
906 <para>The number of CPUs assigned to VM does not improve network
907 performance and in some cases may hurt it due to increased concurrency in
908 the guest.</para>
909 <para>Here is the short summary of things to check in order to improve
910 network performance:</para>
911 <para><orderedlist>
912 <listitem>
913 <para>Whenever possible use <emphasis>virtio</emphasis> network
914 adapter, otherwise use one of <emphasis>Intel PRO/1000</emphasis>
915 adapters;</para>
916 </listitem>
917 <listitem>
918 <para>Use <emphasis>bridged</emphasis> attachment instead of
919 <emphasis>NAT</emphasis></para>;
920 </listitem>
921 <listitem>
922 <para>Make sure segmentation offloading is enabled in the guest OS.
923 Usually it will be enabled by default. You can check and modify
924 offloading settings using <computeroutput>ethtool</computeroutput>
925 command in Linux guests.</para>
926 </listitem>
927 </orderedlist></para>
928 </sect1>
929</chapter>
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette