1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
2 | <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"[
|
---|
4 | <!ENTITY % all.entities SYSTEM "all-entities.ent">
|
---|
5 | %all.entities;
|
---|
6 | ]>
|
---|
7 | <chapter id="networkingdetails">
|
---|
8 |
|
---|
9 | <title>Virtual Networking</title>
|
---|
10 |
|
---|
11 | <para>
|
---|
12 | As mentioned in <xref linkend="settings-network" />, &product-name;
|
---|
13 | provides up to eight virtual PCI Ethernet cards for each virtual
|
---|
14 | machine. For each such card, you can individually select the
|
---|
15 | following:
|
---|
16 | </para>
|
---|
17 |
|
---|
18 | <itemizedlist>
|
---|
19 |
|
---|
20 | <listitem>
|
---|
21 | <para>
|
---|
22 | The hardware that will be virtualized.
|
---|
23 | </para>
|
---|
24 | </listitem>
|
---|
25 |
|
---|
26 | <listitem>
|
---|
27 | <para>
|
---|
28 | The virtualization mode that the virtual card operates in, with
|
---|
29 | respect to your physical networking hardware on the host.
|
---|
30 | </para>
|
---|
31 | </listitem>
|
---|
32 |
|
---|
33 | </itemizedlist>
|
---|
34 |
|
---|
35 | <para>
|
---|
36 | Four of the network cards can be configured in the
|
---|
37 | <emphasis role="bold">Network</emphasis> section of the
|
---|
38 | <emphasis role="bold">Settings</emphasis> dialog in the graphical
|
---|
39 | user interface of &product-name;. You can configure all eight
|
---|
40 | network cards on the command line using <command>VBoxManage
|
---|
41 | modifyvm</command>. See <xref linkend="vboxmanage-modifyvm" />.
|
---|
42 | </para>
|
---|
43 |
|
---|
44 | <para>
|
---|
45 | This chapter explains the various networking settings in more
|
---|
46 | detail.
|
---|
47 | </para>
|
---|
48 |
|
---|
49 | <sect1 id="nichardware">
|
---|
50 |
|
---|
51 | <title>Virtual Networking Hardware</title>
|
---|
52 |
|
---|
53 | <para>
|
---|
54 | For each card, you can individually select what kind of
|
---|
55 | <emphasis>hardware</emphasis> will be presented to the virtual
|
---|
56 | machine. &product-name; can virtualize the following types of
|
---|
57 | networking hardware:
|
---|
58 | </para>
|
---|
59 |
|
---|
60 | <itemizedlist>
|
---|
61 |
|
---|
62 | <listitem>
|
---|
63 | <para>
|
---|
64 | AMD PCNet PCI II (Am79C970A)
|
---|
65 | </para>
|
---|
66 | </listitem>
|
---|
67 |
|
---|
68 | <listitem>
|
---|
69 | <para>
|
---|
70 | AMD PCNet FAST III (Am79C973), the default setting
|
---|
71 | </para>
|
---|
72 | </listitem>
|
---|
73 |
|
---|
74 | <listitem>
|
---|
75 | <para>
|
---|
76 | Intel PRO/1000 MT Desktop (82540EM)
|
---|
77 | </para>
|
---|
78 | </listitem>
|
---|
79 |
|
---|
80 | <listitem>
|
---|
81 | <para>
|
---|
82 | Intel PRO/1000 T Server (82543GC)
|
---|
83 | </para>
|
---|
84 | </listitem>
|
---|
85 |
|
---|
86 | <listitem>
|
---|
87 | <para>
|
---|
88 | Intel PRO/1000 MT Server (82545EM)
|
---|
89 | </para>
|
---|
90 | </listitem>
|
---|
91 |
|
---|
92 | <listitem>
|
---|
93 | <para>
|
---|
94 | Paravirtualized network adapter (virtio-net)
|
---|
95 | </para>
|
---|
96 | </listitem>
|
---|
97 |
|
---|
98 | </itemizedlist>
|
---|
99 |
|
---|
100 | <para>
|
---|
101 | The PCNet FAST III is the default because it is supported by
|
---|
102 | nearly all operating systems, as well as by the GNU GRUB boot
|
---|
103 | manager. As an exception, the Intel PRO/1000 family adapters are
|
---|
104 | chosen for some guest operating system types that no longer ship
|
---|
105 | with drivers for the PCNet card, such as Windows Vista.
|
---|
106 | </para>
|
---|
107 |
|
---|
108 | <para>
|
---|
109 | The Intel PRO/1000 MT Desktop type works with Windows Vista and
|
---|
110 | later versions. The T Server variant of the Intel PRO/1000 card is
|
---|
111 | recognized by Windows XP guests without additional driver
|
---|
112 | installation. The MT Server variant facilitates OVF imports from
|
---|
113 | other platforms.
|
---|
114 | </para>
|
---|
115 |
|
---|
116 | <para>
|
---|
117 | The Paravirtualized network adapter (virtio-net) is special. If
|
---|
118 | you select this adapter, then &product-name; does
|
---|
119 | <emphasis>not</emphasis> virtualize common networking hardware
|
---|
120 | that is supported by common guest operating systems. Instead,
|
---|
121 | &product-name; expects a special software interface for
|
---|
122 | virtualized environments to be provided by the guest, thus
|
---|
123 | avoiding the complexity of emulating networking hardware and
|
---|
124 | improving network performance. &product-name; provides support for
|
---|
125 | the industry-standard <emphasis>virtio</emphasis> networking
|
---|
126 | drivers, which are part of the open source KVM project.
|
---|
127 | </para>
|
---|
128 |
|
---|
129 | <para>
|
---|
130 | The virtio networking drivers are available for the following
|
---|
131 | guest operating systems:
|
---|
132 | </para>
|
---|
133 |
|
---|
134 | <itemizedlist>
|
---|
135 |
|
---|
136 | <listitem>
|
---|
137 | <para>
|
---|
138 | Linux kernels version 2.6.25 or later can be configured to
|
---|
139 | provide virtio support. Some distributions have also
|
---|
140 | back-ported virtio to older kernels.
|
---|
141 | </para>
|
---|
142 | </listitem>
|
---|
143 |
|
---|
144 | <listitem>
|
---|
145 | <para>
|
---|
146 | For Windows 2000, XP, and Vista, virtio drivers can be
|
---|
147 | downloaded and installed from the KVM project web page:
|
---|
148 | </para>
|
---|
149 |
|
---|
150 | <para>
|
---|
151 | <ulink
|
---|
152 | url="http://www.linux-kvm.org/page/WindowsGuestDrivers">http://www.linux-kvm.org/page/WindowsGuestDrivers</ulink>.
|
---|
153 | </para>
|
---|
154 | </listitem>
|
---|
155 |
|
---|
156 | </itemizedlist>
|
---|
157 |
|
---|
158 | <para>
|
---|
159 | &product-name; also has limited support for <emphasis>jumbo
|
---|
160 | frames</emphasis>. These are networking packets with more than
|
---|
161 | 1500 bytes of data, provided that you use the Intel card
|
---|
162 | virtualization and bridged networking. Jumbo frames are not
|
---|
163 | supported with the AMD networking devices. In those cases, jumbo
|
---|
164 | packets will silently be dropped for both the transmit and the
|
---|
165 | receive direction. Guest operating systems trying to use this
|
---|
166 | feature will observe this as a packet loss, which may lead to
|
---|
167 | unexpected application behavior in the guest. This does not cause
|
---|
168 | problems with guest operating systems in their default
|
---|
169 | configuration, as jumbo frames need to be explicitly enabled.
|
---|
170 | </para>
|
---|
171 |
|
---|
172 | </sect1>
|
---|
173 |
|
---|
174 | <sect1 id="networkingmodes">
|
---|
175 |
|
---|
176 | <title>Introduction to Networking Modes</title>
|
---|
177 |
|
---|
178 | <para>
|
---|
179 | Each of the networking adapters can be separately configured to
|
---|
180 | operate in one of the following modes:
|
---|
181 | </para>
|
---|
182 |
|
---|
183 | <itemizedlist>
|
---|
184 |
|
---|
185 | <listitem>
|
---|
186 | <para>
|
---|
187 | <emphasis role="bold">Not attached.</emphasis> In this mode,
|
---|
188 | &product-name; reports to the guest that a network card is
|
---|
189 | present, but that there is no connection. This is as if no
|
---|
190 | Ethernet cable was plugged into the card. Using this mode, it
|
---|
191 | is possible to "pull" the virtual Ethernet cable and disrupt
|
---|
192 | the connection, which can be useful to inform a guest
|
---|
193 | operating system that no network connection is available and
|
---|
194 | enforce a reconfiguration.
|
---|
195 | </para>
|
---|
196 | </listitem>
|
---|
197 |
|
---|
198 | <listitem>
|
---|
199 | <para>
|
---|
200 | <emphasis role="bold">Network Address Translation
|
---|
201 | (NAT)</emphasis>. If all you want is to browse the Web,
|
---|
202 | download files, and view email inside the guest, then this
|
---|
203 | default mode should be sufficient for you, and you can skip
|
---|
204 | the rest of this section. Please note that there are certain
|
---|
205 | limitations when using Windows file sharing. See
|
---|
206 | <xref linkend="nat-limitations" />.
|
---|
207 | </para>
|
---|
208 | </listitem>
|
---|
209 |
|
---|
210 | <listitem>
|
---|
211 | <para>
|
---|
212 | <emphasis role="bold">NAT Network.</emphasis> A NAT network is
|
---|
213 | a type of internal network that allows outbound connections.
|
---|
214 | See <xref linkend="network_nat_service"/>.
|
---|
215 | </para>
|
---|
216 | </listitem>
|
---|
217 |
|
---|
218 | <listitem>
|
---|
219 | <para>
|
---|
220 | <emphasis role="bold">Bridged networking.</emphasis> This is
|
---|
221 | for more advanced networking needs, such as network
|
---|
222 | simulations and running servers in a guest. When enabled,
|
---|
223 | &product-name; connects to one of your installed network cards
|
---|
224 | and exchanges network packets directly, circumventing your
|
---|
225 | host operating system's network stack.
|
---|
226 | </para>
|
---|
227 | </listitem>
|
---|
228 |
|
---|
229 | <listitem>
|
---|
230 | <para>
|
---|
231 | <emphasis role="bold">Internal networking.</emphasis> This can
|
---|
232 | be used to create a different kind of software-based network
|
---|
233 | which is visible to selected virtual machines, but not to
|
---|
234 | applications running on the host or to the outside world.
|
---|
235 | </para>
|
---|
236 | </listitem>
|
---|
237 |
|
---|
238 | <listitem>
|
---|
239 | <para>
|
---|
240 | <emphasis role="bold">Host-only networking.</emphasis> This
|
---|
241 | can be used to create a network containing the host and a set
|
---|
242 | of virtual machines, without the need for the host's physical
|
---|
243 | network interface. Instead, a virtual network interface,
|
---|
244 | similar to a loopback interface, is created on the host,
|
---|
245 | providing connectivity among virtual machines and the host.
|
---|
246 | </para>
|
---|
247 | </listitem>
|
---|
248 |
|
---|
249 | <listitem>
|
---|
250 | <para>
|
---|
251 | <emphasis role="bold"> Generic networking.</emphasis> Rarely
|
---|
252 | used modes which share the same generic network interface, by
|
---|
253 | allowing the user to select a driver which can be included
|
---|
254 | with &product-name; or be distributed in an extension pack.
|
---|
255 | </para>
|
---|
256 |
|
---|
257 | <para>
|
---|
258 | The following sub-modes are available:
|
---|
259 | </para>
|
---|
260 |
|
---|
261 | <itemizedlist>
|
---|
262 |
|
---|
263 | <listitem>
|
---|
264 | <para>
|
---|
265 | <emphasis role="bold">UDP Tunnel:</emphasis> Used to
|
---|
266 | interconnect virtual machines running on different hosts
|
---|
267 | directly, easily, and transparently, over an existing
|
---|
268 | network infrastructure.
|
---|
269 | </para>
|
---|
270 | </listitem>
|
---|
271 |
|
---|
272 | <listitem>
|
---|
273 | <para>
|
---|
274 | <emphasis role="bold">VDE (Virtual Distributed Ethernet)
|
---|
275 | networking:</emphasis> Used to connect to a Virtual
|
---|
276 | Distributed Ethernet switch on a Linux or a FreeBSD host.
|
---|
277 | At the moment this option requires compilation of
|
---|
278 | &product-name; from sources, as the Oracle packages do not
|
---|
279 | include it.
|
---|
280 | </para>
|
---|
281 | </listitem>
|
---|
282 |
|
---|
283 | </itemizedlist>
|
---|
284 | </listitem>
|
---|
285 |
|
---|
286 | </itemizedlist>
|
---|
287 |
|
---|
288 | <para>
|
---|
289 | The following table provides an overview of the most important
|
---|
290 | networking modes.
|
---|
291 | </para>
|
---|
292 |
|
---|
293 | <table id="table-networking-modes" tabstyle="oracle-all">
|
---|
294 | <title>Overview of Networking Modes</title>
|
---|
295 | <tgroup cols="6">
|
---|
296 | <colspec align="left" />
|
---|
297 | <colspec align="center" />
|
---|
298 | <colspec align="center" />
|
---|
299 | <colspec align="center" />
|
---|
300 | <colspec align="center" />
|
---|
301 | <colspec align="center" />
|
---|
302 | <thead valign="middle">
|
---|
303 | <row>
|
---|
304 | <entry><emphasis role="bold">Mode</emphasis></entry>
|
---|
305 | <entry><para>
|
---|
306 | <emphasis role="bold">VM→Host</emphasis>
|
---|
307 | </para></entry>
|
---|
308 | <entry><para>
|
---|
309 | <emphasis role="bold">VM←Host</emphasis>
|
---|
310 | </para></entry>
|
---|
311 | <entry><para>
|
---|
312 | <emphasis role="bold">VM1↔VM2</emphasis>
|
---|
313 | </para></entry>
|
---|
314 | <entry><para>
|
---|
315 | <emphasis role="bold">VM→Net/LAN</emphasis>
|
---|
316 | </para></entry>
|
---|
317 | <entry><para>
|
---|
318 | <emphasis role="bold">VM←Net/LAN</emphasis>
|
---|
319 | </para></entry>
|
---|
320 | </row>
|
---|
321 | </thead>
|
---|
322 | <tbody valign="middle">
|
---|
323 | <row>
|
---|
324 | <entry><para>
|
---|
325 | Host-only
|
---|
326 | </para></entry>
|
---|
327 | <entry><para>
|
---|
328 | <emphasis role="bold">+</emphasis>
|
---|
329 | </para></entry>
|
---|
330 | <entry><para>
|
---|
331 | <emphasis role="bold">+</emphasis>
|
---|
332 | </para></entry>
|
---|
333 | <entry align="center"><para>
|
---|
334 | <emphasis role="bold">+</emphasis>
|
---|
335 | </para></entry>
|
---|
336 | <entry><para>
|
---|
337 | –
|
---|
338 | </para></entry>
|
---|
339 | <entry><para>
|
---|
340 | –
|
---|
341 | </para></entry>
|
---|
342 | </row>
|
---|
343 | <row>
|
---|
344 | <entry><para>
|
---|
345 | Internal
|
---|
346 | </para></entry>
|
---|
347 | <entry><para>
|
---|
348 | –
|
---|
349 | </para></entry>
|
---|
350 | <entry><para>
|
---|
351 | –
|
---|
352 | </para></entry>
|
---|
353 | <entry><para>
|
---|
354 | <emphasis role="bold">+</emphasis>
|
---|
355 | </para></entry>
|
---|
356 | <entry><para>
|
---|
357 | –
|
---|
358 | </para></entry>
|
---|
359 | <entry><para>
|
---|
360 | –
|
---|
361 | </para></entry>
|
---|
362 | </row>
|
---|
363 | <row>
|
---|
364 | <entry><para>
|
---|
365 | Bridged
|
---|
366 | </para></entry>
|
---|
367 | <entry><para>
|
---|
368 | <emphasis role="bold">+</emphasis>
|
---|
369 | </para></entry>
|
---|
370 | <entry><para>
|
---|
371 | <emphasis role="bold">+</emphasis>
|
---|
372 | </para></entry>
|
---|
373 | <entry><para>
|
---|
374 | <emphasis role="bold">+</emphasis>
|
---|
375 | </para></entry>
|
---|
376 | <entry><para>
|
---|
377 | <emphasis role="bold">+</emphasis>
|
---|
378 | </para></entry>
|
---|
379 | <entry><para>
|
---|
380 | <emphasis role="bold">+</emphasis>
|
---|
381 | </para></entry>
|
---|
382 | </row>
|
---|
383 | <row>
|
---|
384 | <entry><para>
|
---|
385 | NAT
|
---|
386 | </para></entry>
|
---|
387 | <entry><para>
|
---|
388 | <emphasis role="bold">+</emphasis>
|
---|
389 | </para></entry>
|
---|
390 | <entry><para>
|
---|
391 | <link linkend="natforward">Port forward</link>
|
---|
392 | </para></entry>
|
---|
393 | <entry><para>
|
---|
394 | –
|
---|
395 | </para></entry>
|
---|
396 | <entry><para>
|
---|
397 | <emphasis role="bold">+</emphasis>
|
---|
398 | </para></entry>
|
---|
399 | <entry><para>
|
---|
400 | <link linkend="natforward">Port forward</link>
|
---|
401 | </para></entry>
|
---|
402 | </row>
|
---|
403 | <row>
|
---|
404 | <entry><para>
|
---|
405 | NATservice
|
---|
406 | </para></entry>
|
---|
407 | <entry><para>
|
---|
408 | <emphasis role="bold">+</emphasis>
|
---|
409 | </para></entry>
|
---|
410 | <entry><para>
|
---|
411 | <link linkend="network_nat_service">Port forward</link>
|
---|
412 | </para></entry>
|
---|
413 | <entry><para>
|
---|
414 | <emphasis role="bold">+</emphasis>
|
---|
415 | </para></entry>
|
---|
416 | <entry><para>
|
---|
417 | <emphasis role="bold">+</emphasis>
|
---|
418 | </para></entry>
|
---|
419 | <entry><para>
|
---|
420 | <link linkend="network_nat_service">Port forward</link>
|
---|
421 | </para></entry>
|
---|
422 | </row>
|
---|
423 | </tbody>
|
---|
424 | </tgroup>
|
---|
425 | </table>
|
---|
426 |
|
---|
427 | <para>
|
---|
428 | The following sections describe the available network modes in
|
---|
429 | more detail.
|
---|
430 | </para>
|
---|
431 |
|
---|
432 | </sect1>
|
---|
433 |
|
---|
434 | <sect1 id="network_nat">
|
---|
435 |
|
---|
436 | <title>Network Address Translation (NAT)</title>
|
---|
437 |
|
---|
438 | <para>
|
---|
439 | Network Address Translation (NAT) is the simplest way of accessing
|
---|
440 | an external network from a virtual machine. Usually, it does not
|
---|
441 | require any configuration on the host network and guest system.
|
---|
442 | For this reason, it is the default networking mode in
|
---|
443 | &product-name;.
|
---|
444 | </para>
|
---|
445 |
|
---|
446 | <para>
|
---|
447 | A virtual machine with NAT enabled acts much like a real computer
|
---|
448 | that connects to the Internet through a router. The router, in
|
---|
449 | this case, is the &product-name; networking engine, which maps
|
---|
450 | traffic from and to the virtual machine transparently. In
|
---|
451 | &product-name; this router is placed between each virtual machine
|
---|
452 | and the host. This separation maximizes security since by default
|
---|
453 | virtual machines cannot talk to each other.
|
---|
454 | </para>
|
---|
455 |
|
---|
456 | <para>
|
---|
457 | The disadvantage of NAT mode is that, much like a private network
|
---|
458 | behind a router, the virtual machine is invisible and unreachable
|
---|
459 | from the outside internet. You cannot run a server this way unless
|
---|
460 | you set up port forwarding. See <xref linkend="natforward"/>.
|
---|
461 | </para>
|
---|
462 |
|
---|
463 | <para>
|
---|
464 | The network frames sent out by the guest operating system are
|
---|
465 | received by &product-name;'s NAT engine, which extracts the TCP/IP
|
---|
466 | data and resends it using the host operating system. To an
|
---|
467 | application on the host, or to another computer on the same
|
---|
468 | network as the host, it looks like the data was sent by the
|
---|
469 | &product-name; application on the host, using an IP address
|
---|
470 | belonging to the host. &product-name; listens for replies to the
|
---|
471 | packages sent, and repacks and resends them to the guest machine
|
---|
472 | on its private network.
|
---|
473 | </para>
|
---|
474 |
|
---|
475 | <para>
|
---|
476 | The virtual machine receives its network address and configuration
|
---|
477 | on the private network from a DHCP server integrated into
|
---|
478 | &product-name;. The IP address thus assigned to the virtual
|
---|
479 | machine is usually on a completely different network than the
|
---|
480 | host. As more than one card of a virtual machine can be set up to
|
---|
481 | use NAT, the first card is connected to the private network
|
---|
482 | 10.0.2.0, the second card to the network 10.0.3.0 and so on. If
|
---|
483 | you need to change the guest-assigned IP range, see
|
---|
484 | <xref linkend="changenat" />.
|
---|
485 | </para>
|
---|
486 |
|
---|
487 | <sect2 id="natforward">
|
---|
488 |
|
---|
489 | <title>Configuring Port Forwarding with NAT</title>
|
---|
490 |
|
---|
491 | <para>
|
---|
492 | As the virtual machine is connected to a private network
|
---|
493 | internal to &product-name; and invisible to the host, network
|
---|
494 | services on the guest are not accessible to the host machine or
|
---|
495 | to other computers on the same network. However, like a physical
|
---|
496 | router, &product-name; can make selected services available to
|
---|
497 | the world outside the guest through <emphasis>port
|
---|
498 | forwarding</emphasis>. This means that &product-name; listens to
|
---|
499 | certain ports on the host and resends all packets which arrive
|
---|
500 | there to the guest, on the same or a different port.
|
---|
501 | </para>
|
---|
502 |
|
---|
503 | <para>
|
---|
504 | To an application on the host or other physical or virtual
|
---|
505 | machines on the network, it looks as though the service being
|
---|
506 | proxied is actually running on the host. This also means that
|
---|
507 | you cannot run the same service on the same ports on the host.
|
---|
508 | However, you still gain the advantages of running the service in
|
---|
509 | a virtual machine. For example, services on the host machine or
|
---|
510 | on other virtual machines cannot be compromised or crashed by a
|
---|
511 | vulnerability or a bug in the service, and the service can run
|
---|
512 | in a different operating system than the host system.
|
---|
513 | </para>
|
---|
514 |
|
---|
515 | <para>
|
---|
516 | To configure port forwarding you can use the graphical
|
---|
517 | <emphasis role="bold">Port Forwarding</emphasis> editor which
|
---|
518 | can be found in the <emphasis role="bold">Network
|
---|
519 | Settings</emphasis> dialog for network adaptors configured to
|
---|
520 | use NAT. Here, you can map host ports to guest ports to allow
|
---|
521 | network traffic to be routed to a specific port in the guest.
|
---|
522 | </para>
|
---|
523 |
|
---|
524 | <para>
|
---|
525 | Alternatively, the command line tool
|
---|
526 | <command>VBoxManage</command> can be used. See
|
---|
527 | <xref linkend="vboxmanage-modifyvm" />.
|
---|
528 | </para>
|
---|
529 |
|
---|
530 | <para>
|
---|
531 | You will need to know which ports on the guest the service uses
|
---|
532 | and to decide which ports to use on the host. You may want to
|
---|
533 | use the same ports on the guest and on the host. You can use any
|
---|
534 | ports on the host which are not already in use by a service. For
|
---|
535 | example, to set up incoming NAT connections to an
|
---|
536 | <computeroutput>ssh</computeroutput> server in the guest, use
|
---|
537 | the following command:
|
---|
538 | </para>
|
---|
539 |
|
---|
540 | <screen>VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"</screen>
|
---|
541 |
|
---|
542 | <para>
|
---|
543 | In the above example, all TCP traffic arriving on port 2222 on
|
---|
544 | any host interface will be forwarded to port 22 in the guest.
|
---|
545 | The protocol name <computeroutput>tcp</computeroutput> is a
|
---|
546 | mandatory attribute defining which protocol should be used for
|
---|
547 | forwarding, <computeroutput>udp</computeroutput> could also be
|
---|
548 | used. The name <computeroutput>guestssh</computeroutput> is
|
---|
549 | purely descriptive and will be auto-generated if omitted. The
|
---|
550 | number after <option>--natpf</option> denotes the network card,
|
---|
551 | as with other <command>VBoxManage</command> commands.
|
---|
552 | </para>
|
---|
553 |
|
---|
554 | <para>
|
---|
555 | To remove this forwarding rule, use the following command:
|
---|
556 | </para>
|
---|
557 |
|
---|
558 | <screen>VBoxManage modifyvm "VM name" --natpf1 delete "guestssh"</screen>
|
---|
559 |
|
---|
560 | <para>
|
---|
561 | If for some reason the guest uses a static assigned IP address
|
---|
562 | not leased from the built-in DHCP server, it is required to
|
---|
563 | specify the guest IP when registering the forwarding rule, as
|
---|
564 | follows:
|
---|
565 | </para>
|
---|
566 |
|
---|
567 | <screen>VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,10.0.2.19,22"</screen>
|
---|
568 |
|
---|
569 | <para>
|
---|
570 | This example is identical to the previous one, except that the
|
---|
571 | NAT engine is being told that the guest can be found at the
|
---|
572 | 10.0.2.19 address.
|
---|
573 | </para>
|
---|
574 |
|
---|
575 | <para>
|
---|
576 | To forward <emphasis>all</emphasis> incoming traffic from a
|
---|
577 | specific host interface to the guest, specify the IP of that
|
---|
578 | host interface as follows:
|
---|
579 | </para>
|
---|
580 |
|
---|
581 | <screen>VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,127.0.0.1,2222,,22"</screen>
|
---|
582 |
|
---|
583 | <para>
|
---|
584 | This example forwards all TCP traffic arriving on the localhost
|
---|
585 | interface at 127.0.0.1 through port 2222 to port 22 in the
|
---|
586 | guest.
|
---|
587 | </para>
|
---|
588 |
|
---|
589 | <para>
|
---|
590 | It is possible to configure incoming NAT connections while the
|
---|
591 | VM is running, see <xref linkend="vboxmanage-controlvm"/>.
|
---|
592 | </para>
|
---|
593 |
|
---|
594 | </sect2>
|
---|
595 |
|
---|
596 | <sect2 id="nat-tftp">
|
---|
597 |
|
---|
598 | <title>PXE Booting with NAT</title>
|
---|
599 |
|
---|
600 | <para>
|
---|
601 | PXE booting is now supported in NAT mode. The NAT DHCP server
|
---|
602 | provides a boot file name of the form
|
---|
603 | <computeroutput>vmname.pxe</computeroutput> if the directory
|
---|
604 | <computeroutput>TFTP</computeroutput> exists in the directory
|
---|
605 | where the user's <computeroutput>VirtualBox.xml</computeroutput>
|
---|
606 | file is kept. It is the responsibility of the user to provide
|
---|
607 | <computeroutput>vmname.pxe</computeroutput>.
|
---|
608 | </para>
|
---|
609 |
|
---|
610 | </sect2>
|
---|
611 |
|
---|
612 | <sect2 id="nat-limitations">
|
---|
613 |
|
---|
614 | <title>NAT Limitations</title>
|
---|
615 |
|
---|
616 | <para>
|
---|
617 | There are some limitations of NAT mode which users should be
|
---|
618 | aware of, as follows:
|
---|
619 | </para>
|
---|
620 |
|
---|
621 | <itemizedlist>
|
---|
622 |
|
---|
623 | <listitem>
|
---|
624 | <para>
|
---|
625 | <emphasis role="bold">ICMP protocol limitations.</emphasis>
|
---|
626 | Some frequently used network debugging tools, such as
|
---|
627 | <computeroutput>ping</computeroutput> or tracerouting, rely
|
---|
628 | on the ICMP protocol for sending and receiving messages.
|
---|
629 | While ICMP support has been improved with &product-name;
|
---|
630 | 2.1, meaning <computeroutput>ping</computeroutput> should
|
---|
631 | now work, some other tools may not work reliably.
|
---|
632 | </para>
|
---|
633 | </listitem>
|
---|
634 |
|
---|
635 | <listitem>
|
---|
636 | <para>
|
---|
637 | <emphasis role="bold">Receiving of UDP
|
---|
638 | broadcasts.</emphasis> The guest does not reliably receive
|
---|
639 | UDP broadcasts. In order to save resources, it only listens
|
---|
640 | for a certain amount of time after the guest has sent UDP
|
---|
641 | data on a particular port. As a consequence, NetBios name
|
---|
642 | resolution based on broadcasts does not always work, but
|
---|
643 | WINS always works. As a workaround, you can use the numeric
|
---|
644 | IP of the desired server in the
|
---|
645 | <computeroutput>\\server\share</computeroutput> notation.
|
---|
646 | </para>
|
---|
647 | </listitem>
|
---|
648 |
|
---|
649 | <listitem>
|
---|
650 | <para>
|
---|
651 | <emphasis role="bold">Some protocols are not
|
---|
652 | supported.</emphasis> Protocols other than TCP and UDP are
|
---|
653 | not supported. GRE is not supported. This means some VPN
|
---|
654 | products, such as PPTP from Microsoft, cannot be used. There
|
---|
655 | are other VPN products which use only TCP and UDP.
|
---|
656 | </para>
|
---|
657 | </listitem>
|
---|
658 |
|
---|
659 | <listitem>
|
---|
660 | <para>
|
---|
661 | <emphasis role="bold">Forwarding host ports below
|
---|
662 | 1024.</emphasis> On UNIX-based hosts, such as Linux, Oracle
|
---|
663 | Solaris, and Mac OS X, it is not possible to bind to ports
|
---|
664 | below 1024 from applications that are not run by
|
---|
665 | <computeroutput>root</computeroutput>. As a result, if you
|
---|
666 | try to configure such a port forwarding, the VM will refuse
|
---|
667 | to start.
|
---|
668 | </para>
|
---|
669 | </listitem>
|
---|
670 |
|
---|
671 | </itemizedlist>
|
---|
672 |
|
---|
673 | <para>
|
---|
674 | These limitations normally do not affect standard network use.
|
---|
675 | But the presence of NAT has also subtle effects that may
|
---|
676 | interfere with protocols that are normally working. One example
|
---|
677 | is NFS, where the server is often configured to refuse
|
---|
678 | connections from non-privileged ports, which are those ports not
|
---|
679 | below 1024.
|
---|
680 | </para>
|
---|
681 |
|
---|
682 | </sect2>
|
---|
683 |
|
---|
684 | </sect1>
|
---|
685 |
|
---|
686 | <sect1 id="network_nat_service">
|
---|
687 |
|
---|
688 | <title>Network Address Translation Service</title>
|
---|
689 |
|
---|
690 | <para>
|
---|
691 | The Network Address Translation (NAT) service works in a similar
|
---|
692 | way to a home router, grouping the systems using it into a network
|
---|
693 | and preventing systems outside of this network from directly
|
---|
694 | accessing systems inside it, but letting systems inside
|
---|
695 | communicate with each other and with systems outside using TCP and
|
---|
696 | UDP over IPv4 and IPv6.
|
---|
697 | </para>
|
---|
698 |
|
---|
699 | <para>
|
---|
700 | A NAT service is attached to an internal network. Virtual machines
|
---|
701 | which are to make use of it should be attached to that internal
|
---|
702 | network. The name of internal network is chosen when the NAT
|
---|
703 | service is created and the internal network will be created if it
|
---|
704 | does not already exist. The following is an example command to
|
---|
705 | create a NAT network:
|
---|
706 | </para>
|
---|
707 |
|
---|
708 | <screen>VBoxManage natnetwork add --netname natnet1 --network "192.168.15.0/24" --enable</screen>
|
---|
709 |
|
---|
710 | <para>
|
---|
711 | Here, natnet1 is the name of the internal network to be used and
|
---|
712 | 192.168.15.0/24 is the network address and mask of the NAT service
|
---|
713 | interface. By default in this static configuration the gateway
|
---|
714 | will be assigned the address 192.168.15.1, the address following
|
---|
715 | the interface address, though this is subject to change. To attach
|
---|
716 | a DHCP server to the internal network, modify the example command
|
---|
717 | as follows:
|
---|
718 | </para>
|
---|
719 |
|
---|
720 | <screen>VBoxManage natnetwork add --netname natnet1 --network "192.168.15.0/24" --enable --dhcp on</screen>
|
---|
721 |
|
---|
722 | <para>
|
---|
723 | To add a DHCP server to an existing network, use the following
|
---|
724 | command:
|
---|
725 | </para>
|
---|
726 |
|
---|
727 | <screen>VBoxManage natnetwork modify --netname natnet1 --dhcp on</screen>
|
---|
728 |
|
---|
729 | <para>
|
---|
730 | To disable the DHCP server, use the following command:
|
---|
731 | </para>
|
---|
732 |
|
---|
733 | <screen>VBoxManage natnetwork modify --netname natnet1 --dhcp off</screen>
|
---|
734 |
|
---|
735 | <para>
|
---|
736 | A DHCP server provides a list of registered nameservers, but does
|
---|
737 | not map servers from the 127/8 network.
|
---|
738 | </para>
|
---|
739 |
|
---|
740 | <para>
|
---|
741 | To start the NAT service, use the following command:
|
---|
742 | </para>
|
---|
743 |
|
---|
744 | <screen>VBoxManage natnetwork start --netname natnet1</screen>
|
---|
745 |
|
---|
746 | <para>
|
---|
747 | If the network has a DHCP server attached then it will start
|
---|
748 | together with the NAT network service.
|
---|
749 | </para>
|
---|
750 |
|
---|
751 | <para>
|
---|
752 | To stop the NAT network service, together with any DHCP server:
|
---|
753 | </para>
|
---|
754 |
|
---|
755 | <screen>VBoxManage natnetwork stop --netname natnet1</screen>
|
---|
756 |
|
---|
757 | <para>
|
---|
758 | To delete the NAT network service:
|
---|
759 | </para>
|
---|
760 |
|
---|
761 | <screen>VBoxManage natnetwork remove --netname natnet1</screen>
|
---|
762 |
|
---|
763 | <para>
|
---|
764 | This command does not remove the DHCP server if one is enabled on
|
---|
765 | the internal network.
|
---|
766 | </para>
|
---|
767 |
|
---|
768 | <para>
|
---|
769 | Port-forwarding is supported, using the
|
---|
770 | <computeroutput>--port-forward-4</computeroutput> switch for IPv4
|
---|
771 | and <computeroutput>--port-forward-6</computeroutput> for IPv6.
|
---|
772 | For example:
|
---|
773 | </para>
|
---|
774 |
|
---|
775 | <screen>VBoxManage natnetwork modify \
|
---|
776 | --netname natnet1 --port-forward-4 "ssh:tcp:[]:1022:[192.168.15.5]:22"</screen>
|
---|
777 |
|
---|
778 | <para>
|
---|
779 | This adds a port-forwarding rule from the host's TCP 1022 port to
|
---|
780 | the port 22 on the guest with IP address 192.168.15.5. Host port,
|
---|
781 | guest port and guest IP are mandatory. To delete the rule, use the
|
---|
782 | following command:
|
---|
783 | </para>
|
---|
784 |
|
---|
785 | <screen>VBoxManage natnetwork modify --netname natnet1 --port-forward-4 delete ssh</screen>
|
---|
786 |
|
---|
787 | <para>
|
---|
788 | It is possible to bind a NAT service to specified interface. For
|
---|
789 | example:
|
---|
790 | </para>
|
---|
791 |
|
---|
792 | <screen>VBoxManage setextradata global "NAT/win-nat-test-0/SourceIp4" 192.168.1.185</screen>
|
---|
793 |
|
---|
794 | <para>
|
---|
795 | To see the list of registered NAT networks, use the following
|
---|
796 | command:
|
---|
797 | </para>
|
---|
798 |
|
---|
799 | <screen>VBoxManage list natnetworks</screen>
|
---|
800 |
|
---|
801 | </sect1>
|
---|
802 |
|
---|
803 | <sect1 id="network_bridged">
|
---|
804 |
|
---|
805 | <title>Bridged Networking</title>
|
---|
806 |
|
---|
807 | <para>
|
---|
808 | With bridged networking, &product-name; uses a device driver on
|
---|
809 | your <emphasis>host</emphasis> system that filters data from your
|
---|
810 | physical network adapter. This driver is therefore called a
|
---|
811 | <emphasis>net filter</emphasis> driver. This enables
|
---|
812 | &product-name; to intercept data from the physical network and
|
---|
813 | inject data into it, effectively creating a new network interface
|
---|
814 | in software. When a guest is using such a new software interface,
|
---|
815 | it looks to the host system as though the guest were physically
|
---|
816 | connected to the interface using a network cable. The host can
|
---|
817 | send data to the guest through that interface and receive data
|
---|
818 | from it. This means that you can set up routing or bridging
|
---|
819 | between the guest and the rest of your network.
|
---|
820 | </para>
|
---|
821 |
|
---|
822 | <note>
|
---|
823 | <para>
|
---|
824 | Even though TAP interfaces are no longer necessary on Linux for
|
---|
825 | bridged networking, you <emphasis>can</emphasis> still use TAP
|
---|
826 | interfaces for certain advanced setups, since you can connect a
|
---|
827 | VM to any host interface.
|
---|
828 | </para>
|
---|
829 | </note>
|
---|
830 |
|
---|
831 | <para>
|
---|
832 | To enable bridged networking, open the
|
---|
833 | <emphasis role="bold">Settings</emphasis> dialog of a virtual
|
---|
834 | machine, go to the <emphasis role="bold">Network</emphasis> page
|
---|
835 | and select <emphasis role="bold">Bridged Network</emphasis> in the
|
---|
836 | drop-down list for the <emphasis role="bold">Attached
|
---|
837 | To</emphasis> field. Select a host interface from the list at the
|
---|
838 | bottom of the page, which contains the physical network interfaces
|
---|
839 | of your systems. On a typical MacBook, for example, this will
|
---|
840 | allow you to select between en1: AirPort, which is the wireless
|
---|
841 | interface, and en0: Ethernet, which represents the interface with
|
---|
842 | a network cable.
|
---|
843 | </para>
|
---|
844 |
|
---|
845 | <note>
|
---|
846 | <para>
|
---|
847 | Bridging to a wireless interface is done differently from
|
---|
848 | bridging to a wired interface, because most wireless adapters do
|
---|
849 | not support promiscuous mode. All traffic has to use the MAC
|
---|
850 | address of the host's wireless adapter, and therefore
|
---|
851 | &product-name; needs to replace the source MAC address in the
|
---|
852 | Ethernet header of an outgoing packet to make sure the reply
|
---|
853 | will be sent to the host interface. When &product-name; sees an
|
---|
854 | incoming packet with a destination IP address that belongs to
|
---|
855 | one of the virtual machine adapters it replaces the destination
|
---|
856 | MAC address in the Ethernet header with the VM adapter's MAC
|
---|
857 | address and passes it on. &product-name; examines ARP and DHCP
|
---|
858 | packets in order to learn the IP addresses of virtual machines.
|
---|
859 | </para>
|
---|
860 | </note>
|
---|
861 |
|
---|
862 | <para>
|
---|
863 | Depending on your host operating system, the following limitations
|
---|
864 | apply:
|
---|
865 | </para>
|
---|
866 |
|
---|
867 | <itemizedlist>
|
---|
868 |
|
---|
869 | <listitem>
|
---|
870 | <para>
|
---|
871 | <emphasis role="bold">Mac OS X hosts.</emphasis> Functionality
|
---|
872 | is limited when using AirPort, the Mac's wireless networking
|
---|
873 | system, for bridged networking. Currently, &product-name;
|
---|
874 | supports only IPv4 and IPv6 over AirPort. For other protocols,
|
---|
875 | such as IPX, you must choose a wired interface.
|
---|
876 | </para>
|
---|
877 | </listitem>
|
---|
878 |
|
---|
879 | <listitem>
|
---|
880 | <para>
|
---|
881 | <emphasis role="bold">Linux hosts.</emphasis> Functionality is
|
---|
882 | limited when using wireless interfaces for bridged networking.
|
---|
883 | Currently, &product-name; supports only IPv4 and IPv6 over
|
---|
884 | wireless. For other protocols, such as IPX, you must choose a
|
---|
885 | wired interface.
|
---|
886 | </para>
|
---|
887 |
|
---|
888 | <para>
|
---|
889 | Also, setting the MTU to less than 1500 bytes on wired
|
---|
890 | interfaces provided by the sky2 driver on the Marvell Yukon II
|
---|
891 | EC Ultra Ethernet NIC is known to cause packet losses under
|
---|
892 | certain conditions.
|
---|
893 | </para>
|
---|
894 |
|
---|
895 | <para>
|
---|
896 | Some adapters strip VLAN tags in hardware. This does not allow
|
---|
897 | you to use VLAN trunking between VM and the external network
|
---|
898 | with pre-2.6.27 Linux kernels, or with host operating systems
|
---|
899 | other than Linux.
|
---|
900 | </para>
|
---|
901 | </listitem>
|
---|
902 |
|
---|
903 | <listitem>
|
---|
904 | <para>
|
---|
905 | <emphasis role="bold">Oracle Solaris hosts.</emphasis> There
|
---|
906 | is no support for using wireless interfaces. Filtering guest
|
---|
907 | traffic using IPFilter is also not completely supported due to
|
---|
908 | technical restrictions of the Oracle Solaris networking
|
---|
909 | subsystem. These issues may be addressed in later releases of
|
---|
910 | Oracle Solaris 11.
|
---|
911 | </para>
|
---|
912 |
|
---|
913 | <para>
|
---|
914 | On Oracle Solaris 11 hosts build 159 and above, it is possible
|
---|
915 | to use Oracle Solaris Crossbow Virtual Network Interfaces
|
---|
916 | (VNICs) directly with &product-name; without any additional
|
---|
917 | configuration other than each VNIC must be exclusive for every
|
---|
918 | guest network interface.
|
---|
919 | </para>
|
---|
920 |
|
---|
921 | <para>
|
---|
922 | When using VLAN interfaces with &product-name;, they must be
|
---|
923 | named according to the PPA-hack naming scheme, such as
|
---|
924 | e1000g513001. Otherwise, the guest may receive packets in an
|
---|
925 | unexpected format.
|
---|
926 | </para>
|
---|
927 | </listitem>
|
---|
928 |
|
---|
929 | </itemizedlist>
|
---|
930 |
|
---|
931 | </sect1>
|
---|
932 |
|
---|
933 | <sect1 id="network_internal">
|
---|
934 |
|
---|
935 | <title>Internal Networking</title>
|
---|
936 |
|
---|
937 | <para>
|
---|
938 | Internal Networking is similar to bridged networking in that the
|
---|
939 | VM can directly communicate with the outside world. However, the
|
---|
940 | outside world is limited to other VMs on the same host which
|
---|
941 | connect to the same internal network.
|
---|
942 | </para>
|
---|
943 |
|
---|
944 | <para>
|
---|
945 | Even though technically, everything that can be done using
|
---|
946 | internal networking can also be done using bridged networking,
|
---|
947 | there are security advantages with internal networking. In bridged
|
---|
948 | networking mode, all traffic goes through a physical interface of
|
---|
949 | the host system. It is therefore possible to attach a packet
|
---|
950 | sniffer such as Wireshark to the host interface and log all
|
---|
951 | traffic that goes over it. If, for any reason, you prefer two or
|
---|
952 | more VMs on the same machine to communicate privately, hiding
|
---|
953 | their data from both the host system and the user, bridged
|
---|
954 | networking therefore is not an option.
|
---|
955 | </para>
|
---|
956 |
|
---|
957 | <para>
|
---|
958 | Internal networks are created automatically as needed. There is no
|
---|
959 | central configuration. Every internal network is identified simply
|
---|
960 | by its name. Once there is more than one active virtual network
|
---|
961 | card with the same internal network ID, the &product-name; support
|
---|
962 | driver will automatically <emphasis>wire</emphasis> the cards and
|
---|
963 | act as a network switch. The &product-name; support driver
|
---|
964 | implements a complete Ethernet switch and supports both
|
---|
965 | broadcast/multicast frames and promiscuous mode.
|
---|
966 | </para>
|
---|
967 |
|
---|
968 | <para>
|
---|
969 | In order to attach a VM's network card to an internal network, set
|
---|
970 | its networking mode to Internal Networking. There are two ways to
|
---|
971 | accomplish this:
|
---|
972 | </para>
|
---|
973 |
|
---|
974 | <itemizedlist>
|
---|
975 |
|
---|
976 | <listitem>
|
---|
977 | <para>
|
---|
978 | Use the VM's <emphasis role="bold">Settings</emphasis> dialog
|
---|
979 | in the &product-name; graphical user interface. In the
|
---|
980 | <emphasis role="bold">Networking</emphasis> category of the
|
---|
981 | settings dialog, select <emphasis role="bold">Internal
|
---|
982 | Networking</emphasis> from the drop-down list of networking
|
---|
983 | modes. Select the name of an existing internal network from
|
---|
984 | the drop-down list below, or enter a new name into the
|
---|
985 | <emphasis role="bold">Name</emphasis> field.
|
---|
986 | </para>
|
---|
987 | </listitem>
|
---|
988 |
|
---|
989 | <listitem>
|
---|
990 | <para>
|
---|
991 | Use the command line, for example:
|
---|
992 | </para>
|
---|
993 |
|
---|
994 | <screen>VBoxManage modifyvm "VM name" --nic<x> intnet</screen>
|
---|
995 |
|
---|
996 | <para>
|
---|
997 | Optionally, you can specify a network name with the command:
|
---|
998 | </para>
|
---|
999 |
|
---|
1000 | <screen>VBoxManage modifyvm "VM name" --intnet<x> "network name"</screen>
|
---|
1001 |
|
---|
1002 | <para>
|
---|
1003 | If you do not specify a network name, the network card will be
|
---|
1004 | attached to the network
|
---|
1005 | <computeroutput>intnet</computeroutput> by default.
|
---|
1006 | </para>
|
---|
1007 | </listitem>
|
---|
1008 |
|
---|
1009 | </itemizedlist>
|
---|
1010 |
|
---|
1011 | <para>
|
---|
1012 | Unless you configure the virtual network cards in the guest
|
---|
1013 | operating systems that are participating in the internal network
|
---|
1014 | to use static IP addresses, you may want to use the DHCP server
|
---|
1015 | that is built into &product-name; to manage IP addresses for the
|
---|
1016 | internal network. See <xref linkend="vboxmanage-dhcpserver" />.
|
---|
1017 | </para>
|
---|
1018 |
|
---|
1019 | <para>
|
---|
1020 | As a security measure, by default, the Linux implementation of
|
---|
1021 | internal networking only allows VMs running under the same user ID
|
---|
1022 | to establish an internal network. However, it is possible to
|
---|
1023 | create a shared internal networking interface, accessible by users
|
---|
1024 | with different user IDs.
|
---|
1025 | </para>
|
---|
1026 |
|
---|
1027 | </sect1>
|
---|
1028 |
|
---|
1029 | <sect1 id="network_hostonly">
|
---|
1030 |
|
---|
1031 | <title>Host-Only Networking</title>
|
---|
1032 |
|
---|
1033 | <para>
|
---|
1034 | Host-only networking is another networking mode that was added
|
---|
1035 | with version 2.2 of &product-name;. It can be thought of as a
|
---|
1036 | hybrid between the bridged and internal networking modes. As with
|
---|
1037 | bridged networking, the virtual machines can talk to each other
|
---|
1038 | and the host as if they were connected through a physical Ethernet
|
---|
1039 | switch. As with internal networking, a physical networking
|
---|
1040 | interface need not be present, and the virtual machines cannot
|
---|
1041 | talk to the world outside the host since they are not connected to
|
---|
1042 | a physical networking interface.
|
---|
1043 | </para>
|
---|
1044 |
|
---|
1045 | <para>
|
---|
1046 | When host-only networking is used, &product-name; creates a new
|
---|
1047 | software interface on the host which then appears next to your
|
---|
1048 | existing network interfaces. In other words, whereas with bridged
|
---|
1049 | networking an existing physical interface is used to attach
|
---|
1050 | virtual machines to, with host-only networking a new
|
---|
1051 | <emphasis>loopback</emphasis> interface is created on the host.
|
---|
1052 | And whereas with internal networking, the traffic between the
|
---|
1053 | virtual machines cannot be seen, the traffic on the loopback
|
---|
1054 | interface on the host can be intercepted.
|
---|
1055 | </para>
|
---|
1056 |
|
---|
1057 | <para>
|
---|
1058 | Host-only networking is particularly useful for preconfigured
|
---|
1059 | virtual appliances, where multiple virtual machines are shipped
|
---|
1060 | together and designed to cooperate. For example, one virtual
|
---|
1061 | machine may contain a web server and a second one a database, and
|
---|
1062 | since they are intended to talk to each other, the appliance can
|
---|
1063 | instruct &product-name; to set up a host-only network for the two.
|
---|
1064 | A second, bridged, network would then connect the web server to
|
---|
1065 | the outside world to serve data to, but the outside world cannot
|
---|
1066 | connect to the database.
|
---|
1067 | </para>
|
---|
1068 |
|
---|
1069 | <para>
|
---|
1070 | To change a virtual machine's virtual network interface to Host
|
---|
1071 | Only mode, do either of the following:
|
---|
1072 | </para>
|
---|
1073 |
|
---|
1074 | <itemizedlist>
|
---|
1075 |
|
---|
1076 | <listitem>
|
---|
1077 | <para>
|
---|
1078 | Go to the <emphasis role="bold">Network</emphasis> page in the
|
---|
1079 | virtual machine's <emphasis role="bold">Settings</emphasis>
|
---|
1080 | dialog and select <emphasis role="bold">Host-Only
|
---|
1081 | Networking</emphasis>.
|
---|
1082 | </para>
|
---|
1083 | </listitem>
|
---|
1084 |
|
---|
1085 | <listitem>
|
---|
1086 | <para>
|
---|
1087 | On the command line, enter <computeroutput>VBoxManage modifyvm
|
---|
1088 | "VM name" --nic<x> hostonly</computeroutput>. See
|
---|
1089 | <xref
|
---|
1090 | linkend="vboxmanage-modifyvm" />.
|
---|
1091 | </para>
|
---|
1092 | </listitem>
|
---|
1093 |
|
---|
1094 | </itemizedlist>
|
---|
1095 |
|
---|
1096 | <para>
|
---|
1097 | Before you can attach a VM to a host-only network you have to
|
---|
1098 | create at least one host-only interface. You can use the GUI for
|
---|
1099 | this. Choose <emphasis role="bold">File</emphasis>,
|
---|
1100 | <emphasis role="bold">Preferences</emphasis>,
|
---|
1101 | <emphasis role="bold">Network</emphasis>,
|
---|
1102 | <emphasis role="bold">Host-Only Network</emphasis>,
|
---|
1103 | <emphasis role="bold">(+)Add Host-Only Network</emphasis>.
|
---|
1104 | </para>
|
---|
1105 |
|
---|
1106 | <para>
|
---|
1107 | Alternatively, you can use the command line:
|
---|
1108 | </para>
|
---|
1109 |
|
---|
1110 | <screen>VBoxManage hostonlyif create</screen>
|
---|
1111 |
|
---|
1112 | <para>
|
---|
1113 | See <xref linkend="vboxmanage-hostonlyif" />.
|
---|
1114 | </para>
|
---|
1115 |
|
---|
1116 | <para>
|
---|
1117 | For host-only networking, as with internal networking, you may
|
---|
1118 | find the DHCP server useful that is built into &product-name;.
|
---|
1119 | This can be enabled to then manage the IP addresses in the
|
---|
1120 | host-only network since otherwise you would need to configure all
|
---|
1121 | IP addresses statically.
|
---|
1122 | </para>
|
---|
1123 |
|
---|
1124 | <itemizedlist>
|
---|
1125 |
|
---|
1126 | <listitem>
|
---|
1127 | <para>
|
---|
1128 | In the &product-name; graphical user interface, you can
|
---|
1129 | configure all these items in the global settings by choosing
|
---|
1130 | <emphasis role="bold">File</emphasis>,
|
---|
1131 | <emphasis role="bold">Preferences</emphasis>,
|
---|
1132 | <emphasis role="bold">Network</emphasis>. This lists all
|
---|
1133 | host-only networks which are presently in use. Click on the
|
---|
1134 | network name and then on
|
---|
1135 | <emphasis role="bold">Edit</emphasis>. You can then modify the
|
---|
1136 | adapter and DHCP settings.
|
---|
1137 | </para>
|
---|
1138 | </listitem>
|
---|
1139 |
|
---|
1140 | <listitem>
|
---|
1141 | <para>
|
---|
1142 | Alternatively, you can use <command>VBoxManage
|
---|
1143 | dhcpserver</command> on the command line. See
|
---|
1144 | <xref
|
---|
1145 | linkend="vboxmanage-dhcpserver" />.
|
---|
1146 | </para>
|
---|
1147 | </listitem>
|
---|
1148 |
|
---|
1149 | </itemizedlist>
|
---|
1150 |
|
---|
1151 | <note>
|
---|
1152 | <para>
|
---|
1153 | On Linux and Mac OS X hosts the number of host-only interfaces
|
---|
1154 | is limited to 128. There is no such limit for Oracle Solaris and
|
---|
1155 | Windows hosts.
|
---|
1156 | </para>
|
---|
1157 | </note>
|
---|
1158 |
|
---|
1159 | </sect1>
|
---|
1160 |
|
---|
1161 | <sect1 id="network_udp_tunnel">
|
---|
1162 |
|
---|
1163 | <title>UDP Tunnel Networking</title>
|
---|
1164 |
|
---|
1165 | <para>
|
---|
1166 | This networking mode enables you to interconnect virtual machines
|
---|
1167 | running on different hosts.
|
---|
1168 | </para>
|
---|
1169 |
|
---|
1170 | <para>
|
---|
1171 | Technically this is done by encapsulating Ethernet frames sent or
|
---|
1172 | received by the guest network card into UDP/IP datagrams, and
|
---|
1173 | sending them over any network available to the host.
|
---|
1174 | </para>
|
---|
1175 |
|
---|
1176 | <para>
|
---|
1177 | UDP Tunnel mode has the following parameters:
|
---|
1178 | </para>
|
---|
1179 |
|
---|
1180 | <itemizedlist>
|
---|
1181 |
|
---|
1182 | <listitem>
|
---|
1183 | <para>
|
---|
1184 | <emphasis role="bold">Source UDP port:</emphasis> The port on
|
---|
1185 | which the host listens. Datagrams arriving on this port from
|
---|
1186 | any source address will be forwarded to the receiving part of
|
---|
1187 | the guest network card.
|
---|
1188 | </para>
|
---|
1189 | </listitem>
|
---|
1190 |
|
---|
1191 | <listitem>
|
---|
1192 | <para>
|
---|
1193 | <emphasis role="bold">Destination address:</emphasis> IP
|
---|
1194 | address of the target host of the transmitted data.
|
---|
1195 | </para>
|
---|
1196 | </listitem>
|
---|
1197 |
|
---|
1198 | <listitem>
|
---|
1199 | <para>
|
---|
1200 | <emphasis role="bold">Destination UDP port:</emphasis> Port
|
---|
1201 | number to which the transmitted data is sent.
|
---|
1202 | </para>
|
---|
1203 | </listitem>
|
---|
1204 |
|
---|
1205 | </itemizedlist>
|
---|
1206 |
|
---|
1207 | <para>
|
---|
1208 | When interconnecting two virtual machines on two different hosts,
|
---|
1209 | their IP addresses must be swapped. On a single host, source and
|
---|
1210 | destination UDP ports must be swapped.
|
---|
1211 | </para>
|
---|
1212 |
|
---|
1213 | <para>
|
---|
1214 | In the following example, host 1 uses the IP address 10.0.0.1 and
|
---|
1215 | host 2 uses IP address 10.0.0.2. To configure using the
|
---|
1216 | command-line:
|
---|
1217 | </para>
|
---|
1218 |
|
---|
1219 | <screen> VBoxManage modifyvm "VM 01 on host 1" --nic<x> generic
|
---|
1220 | VBoxManage modifyvm "VM 01 on host 1" --nicgenericdrv<x> UDPTunnel
|
---|
1221 | VBoxManage modifyvm "VM 01 on host 1" --nicproperty<x> dest=10.0.0.2
|
---|
1222 | VBoxManage modifyvm "VM 01 on host 1" --nicproperty<x> sport=10001
|
---|
1223 | VBoxManage modifyvm "VM 01 on host 1" --nicproperty<x> dport=10002</screen>
|
---|
1224 |
|
---|
1225 | <screen> VBoxManage modifyvm "VM 02 on host 2" --nic<y> generic
|
---|
1226 | VBoxManage modifyvm "VM 02 on host 2" --nicgenericdrv<y> UDPTunnel
|
---|
1227 | VBoxManage modifyvm "VM 02 on host 2" --nicproperty<y> dest=10.0.0.1
|
---|
1228 | VBoxManage modifyvm "VM 02 on host 2" --nicproperty<y> sport=10002
|
---|
1229 | VBoxManage modifyvm "VM 02 on host 2" --nicproperty<y> dport=10001</screen>
|
---|
1230 |
|
---|
1231 | <para>
|
---|
1232 | Of course, you can always interconnect two virtual machines on the
|
---|
1233 | same host, by setting the destination address parameter to
|
---|
1234 | 127.0.0.1 on both. It will act similarly to an internal network in
|
---|
1235 | this case. However, the host can see the network traffic which it
|
---|
1236 | could not in the normal internal network case.
|
---|
1237 | </para>
|
---|
1238 |
|
---|
1239 | <note>
|
---|
1240 | <para>
|
---|
1241 | On UNIX-based hosts, such as Linux, Oracle Solaris, and Mac OS
|
---|
1242 | X, it is not possible to bind to ports below 1024 from
|
---|
1243 | applications that are not run by
|
---|
1244 | <computeroutput>root</computeroutput>. As a result, if you try
|
---|
1245 | to configure such a source UDP port, the VM will refuse to
|
---|
1246 | start.
|
---|
1247 | </para>
|
---|
1248 | </note>
|
---|
1249 |
|
---|
1250 | </sect1>
|
---|
1251 |
|
---|
1252 | <sect1 id="network_vde">
|
---|
1253 |
|
---|
1254 | <title>VDE Networking</title>
|
---|
1255 |
|
---|
1256 | <para>
|
---|
1257 | Virtual Distributed Ethernet (VDE) is a flexible, virtual network
|
---|
1258 | infrastructure system, spanning across multiple hosts in a secure
|
---|
1259 | way. It enables L2/L3 switching, including spanning-tree protocol,
|
---|
1260 | VLANs, and WAN emulation. It is an optional part of &product-name;
|
---|
1261 | which is only included in the source code.
|
---|
1262 | </para>
|
---|
1263 |
|
---|
1264 | <para>
|
---|
1265 | VDE is a project developed by Renzo Davoli, Associate Professor at
|
---|
1266 | the University of Bologna, Italy.
|
---|
1267 | </para>
|
---|
1268 |
|
---|
1269 | <para>
|
---|
1270 | The basic building blocks of the infrastructure are VDE switches,
|
---|
1271 | VDE plugs, and VDE wires which interconnect the switches.
|
---|
1272 | </para>
|
---|
1273 |
|
---|
1274 | <para>
|
---|
1275 | The &product-name; VDE driver has a single parameter: VDE network.
|
---|
1276 | This is the name of the VDE network switch socket to which the VM
|
---|
1277 | will be connected.
|
---|
1278 | </para>
|
---|
1279 |
|
---|
1280 | <para>
|
---|
1281 | The following basic example shows how to connect a virtual machine
|
---|
1282 | to a VDE switch.
|
---|
1283 | </para>
|
---|
1284 |
|
---|
1285 | <orderedlist>
|
---|
1286 |
|
---|
1287 | <listitem>
|
---|
1288 | <para>
|
---|
1289 | Create a VDE switch:
|
---|
1290 | </para>
|
---|
1291 |
|
---|
1292 | <screen>vde_switch -s /tmp/switch1</screen>
|
---|
1293 | </listitem>
|
---|
1294 |
|
---|
1295 | <listitem>
|
---|
1296 | <para>
|
---|
1297 | Configure VMs using the command-line:
|
---|
1298 | </para>
|
---|
1299 |
|
---|
1300 | <screen>VBoxManage modifyvm "VM name" --nic<x> generic</screen>
|
---|
1301 |
|
---|
1302 | <screen>VBoxManage modifyvm "VM name" --nicgenericdrv<x> VDE</screen>
|
---|
1303 |
|
---|
1304 | <para>
|
---|
1305 | To connect to an automatically allocated switch port:
|
---|
1306 | </para>
|
---|
1307 |
|
---|
1308 | <screen>VBoxManage modifyvm "VM name" --nicproperty<x> network=/tmp/switch1</screen>
|
---|
1309 |
|
---|
1310 | <para>
|
---|
1311 | To connect to a specific switch port
|
---|
1312 | <replaceable>n</replaceable>:
|
---|
1313 | </para>
|
---|
1314 |
|
---|
1315 | <screen>VBoxManage modifyvm "VM name" --nicproperty<x> network=/tmp/switch1[<n>]</screen>
|
---|
1316 |
|
---|
1317 | <para>
|
---|
1318 | This command can be useful for VLANs.
|
---|
1319 | </para>
|
---|
1320 | </listitem>
|
---|
1321 |
|
---|
1322 | <listitem>
|
---|
1323 | <para>
|
---|
1324 | (Optional) Map between a VDE switch port and a VLAN.
|
---|
1325 | </para>
|
---|
1326 |
|
---|
1327 | <para>
|
---|
1328 | Using the switch command line:
|
---|
1329 | </para>
|
---|
1330 |
|
---|
1331 | <screen>vde$ vlan/create <VLAN></screen>
|
---|
1332 |
|
---|
1333 | <screen>vde$ port/setvlan <port> <VLAN></screen>
|
---|
1334 | </listitem>
|
---|
1335 |
|
---|
1336 | </orderedlist>
|
---|
1337 |
|
---|
1338 | <para>
|
---|
1339 | VDE is available on Linux and FreeBSD hosts only. It is only
|
---|
1340 | available if the VDE software and the VDE plugin library from the
|
---|
1341 | VirtualSquare project are installed on the host system.
|
---|
1342 | </para>
|
---|
1343 |
|
---|
1344 | <note>
|
---|
1345 | <para>
|
---|
1346 | For Linux hosts, the shared library libvdeplug.so must be
|
---|
1347 | available in the search path for shared libraries.
|
---|
1348 | </para>
|
---|
1349 | </note>
|
---|
1350 |
|
---|
1351 | <para>
|
---|
1352 | For more information on setting up VDE networks, please see the
|
---|
1353 | documentation accompanying the software. See also
|
---|
1354 | <ulink
|
---|
1355 | url="http://wiki.virtualsquare.org/wiki/index.php/VDE_Basic_Networking">http://wiki.virtualsquare.org/wiki/index.php/VDE_Basic_Networking</ulink>.
|
---|
1356 | </para>
|
---|
1357 |
|
---|
1358 | </sect1>
|
---|
1359 |
|
---|
1360 | <sect1 id="network_bandwidth_limit">
|
---|
1361 |
|
---|
1362 | <title>Limiting Bandwidth for Network Input/Output</title>
|
---|
1363 |
|
---|
1364 | <para>
|
---|
1365 | &product-name; supports limiting of the maximum bandwidth used for
|
---|
1366 | network transmission. Several network adapters of one VM may share
|
---|
1367 | limits through bandwidth groups. It is possible to have more than
|
---|
1368 | one such limit.
|
---|
1369 | </para>
|
---|
1370 |
|
---|
1371 | <note>
|
---|
1372 | <para>
|
---|
1373 | &product-name; shapes VM traffic only in the transmit direction,
|
---|
1374 | delaying the packets being sent by virtual machines. It does not
|
---|
1375 | limit the traffic being received by virtual machines.
|
---|
1376 | </para>
|
---|
1377 | </note>
|
---|
1378 |
|
---|
1379 | <para>
|
---|
1380 | Limits are configured through <command>VBoxManage</command>. The
|
---|
1381 | following example creates a bandwidth group named Limit, sets the
|
---|
1382 | limit to 20 Mbps and assigns the group to the first and second
|
---|
1383 | adapters of the VM:
|
---|
1384 | </para>
|
---|
1385 |
|
---|
1386 | <screen>VBoxManage bandwidthctl "VM name" add Limit --type network --limit 20m
|
---|
1387 | VBoxManage modifyvm "VM name" --nicbandwidthgroup1 Limit
|
---|
1388 | VBoxManage modifyvm "VM name" --nicbandwidthgroup2 Limit</screen>
|
---|
1389 |
|
---|
1390 | <para>
|
---|
1391 | All adapters in a group share the bandwidth limit, meaning that in
|
---|
1392 | the example above the bandwidth of both adapters combined can
|
---|
1393 | never exceed 20 Mbps. However, if one adapter does not require
|
---|
1394 | bandwidth the other can use the remaining bandwidth of its group.
|
---|
1395 | </para>
|
---|
1396 |
|
---|
1397 | <para>
|
---|
1398 | The limits for each group can be changed while the VM is running,
|
---|
1399 | with changes being picked up immediately. The following example
|
---|
1400 | changes the limit for the group created in the previous example to
|
---|
1401 | 100 Kbps:
|
---|
1402 | </para>
|
---|
1403 |
|
---|
1404 | <screen>VBoxManage bandwidthctl "VM name" set Limit --limit 100k</screen>
|
---|
1405 |
|
---|
1406 | <para>
|
---|
1407 | To completely disable shaping for the first adapter of VM use the
|
---|
1408 | following command:
|
---|
1409 | </para>
|
---|
1410 |
|
---|
1411 | <screen>VBoxManage modifyvm "VM name" --nicbandwidthgroup1 none</screen>
|
---|
1412 |
|
---|
1413 | <para>
|
---|
1414 | It is also possible to disable shaping for all adapters assigned
|
---|
1415 | to a bandwidth group while VM is running, by specifying the zero
|
---|
1416 | limit for the group. For example, for the bandwidth group named
|
---|
1417 | Limit:
|
---|
1418 | </para>
|
---|
1419 |
|
---|
1420 | <screen>VBoxManage bandwidthctl "VM name" set Limit --limit 0</screen>
|
---|
1421 |
|
---|
1422 | </sect1>
|
---|
1423 |
|
---|
1424 | <sect1 id="network_performance">
|
---|
1425 |
|
---|
1426 | <title>Improving Network Performance</title>
|
---|
1427 |
|
---|
1428 | <para>
|
---|
1429 | &product-name; provides a variety of virtual network adapters that
|
---|
1430 | can be attached to the host's network in a number of ways.
|
---|
1431 | Depending on which types of adapters and attachments are used the
|
---|
1432 | network performance will be different. Performance-wise the virtio
|
---|
1433 | network adapter is preferable over Intel PRO/1000 emulated
|
---|
1434 | adapters, which are preferred over the PCNet family of adapters.
|
---|
1435 | Both virtio and Intel PRO/1000 adapters enjoy the benefit of
|
---|
1436 | segmentation and checksum offloading. Segmentation offloading is
|
---|
1437 | essential for high performance as it allows for less context
|
---|
1438 | switches, dramatically increasing the sizes of packets that cross
|
---|
1439 | the VM/host boundary.
|
---|
1440 | </para>
|
---|
1441 |
|
---|
1442 | <note>
|
---|
1443 | <para>
|
---|
1444 | Neither virtio nor Intel PRO/1000 drivers for Windows XP support
|
---|
1445 | segmentation offloading. Therefore Windows XP guests never reach
|
---|
1446 | the same transmission rates as other guest types. Refer to MS
|
---|
1447 | Knowledge base article 842264 for additional information.
|
---|
1448 | </para>
|
---|
1449 | </note>
|
---|
1450 |
|
---|
1451 | <para>
|
---|
1452 | Three attachment types: Internal, Bridged, and Host-Only, have
|
---|
1453 | nearly identical performance. The Internal type is a little bit
|
---|
1454 | faster and uses less CPU cycles as the packets never reach the
|
---|
1455 | host's network stack. The NAT attachment type is the slowest and
|
---|
1456 | most secure of all attachment types, as it provides network
|
---|
1457 | address translation. The generic driver attachment is special and
|
---|
1458 | cannot be considered as an alternative to other attachment types.
|
---|
1459 | </para>
|
---|
1460 |
|
---|
1461 | <para>
|
---|
1462 | The number of CPUs assigned to VM does not improve network
|
---|
1463 | performance and in some cases may hurt it due to increased
|
---|
1464 | concurrency in the guest.
|
---|
1465 | </para>
|
---|
1466 |
|
---|
1467 | <para>
|
---|
1468 | Here is a short summary of things to check in order to improve
|
---|
1469 | network performance:
|
---|
1470 | </para>
|
---|
1471 |
|
---|
1472 | <itemizedlist>
|
---|
1473 |
|
---|
1474 | <listitem>
|
---|
1475 | <para>
|
---|
1476 | Whenever possible use the virtio network adapter. Otherwise,
|
---|
1477 | use one of the Intel PRO/1000 adapters.
|
---|
1478 | </para>
|
---|
1479 | </listitem>
|
---|
1480 |
|
---|
1481 | <listitem>
|
---|
1482 | <para>
|
---|
1483 | Use a Bridged attachment instead of NAT.
|
---|
1484 | </para>
|
---|
1485 | </listitem>
|
---|
1486 |
|
---|
1487 | <listitem>
|
---|
1488 | <para>
|
---|
1489 | Make sure segmentation offloading is enabled in the guest OS.
|
---|
1490 | Usually it will be enabled by default. You can check and
|
---|
1491 | modify offloading settings using the
|
---|
1492 | <command>ethtool</command> command on Linux guests.
|
---|
1493 | </para>
|
---|
1494 | </listitem>
|
---|
1495 |
|
---|
1496 | <listitem>
|
---|
1497 | <para>
|
---|
1498 | Perform a full detailed analysis of network traffic on the
|
---|
1499 | VM's network adaptor using a third party tool such as
|
---|
1500 | Wireshark. To do this, a promiscuous mode policy needs to be
|
---|
1501 | used on the VM's network adaptor. Use of this mode is only
|
---|
1502 | possible on the following network types: NAT Network, Bridged
|
---|
1503 | Adapter, Internal Network, and Host-Only Adapter.
|
---|
1504 | </para>
|
---|
1505 |
|
---|
1506 | <para>
|
---|
1507 | To setup a promiscuous mode policy, either select from the
|
---|
1508 | drop down list located in the <emphasis role="bold">Network
|
---|
1509 | Settings</emphasis> dialog for the network adaptor or use the
|
---|
1510 | command line tool <command>VBoxManage</command>. See
|
---|
1511 | <xref linkend="vboxmanage-modifyvm" />.
|
---|
1512 | </para>
|
---|
1513 |
|
---|
1514 | <para>
|
---|
1515 | Promiscuous mode policies are as follows:
|
---|
1516 | </para>
|
---|
1517 |
|
---|
1518 | <itemizedlist>
|
---|
1519 |
|
---|
1520 | <listitem>
|
---|
1521 | <para>
|
---|
1522 | <computeroutput>deny</computeroutput>, which hides any
|
---|
1523 | traffic not intended for the VM's network adaptor. This is
|
---|
1524 | the default setting.
|
---|
1525 | </para>
|
---|
1526 | </listitem>
|
---|
1527 |
|
---|
1528 | <listitem>
|
---|
1529 | <para>
|
---|
1530 | <computeroutput>allow-vms</computeroutput>, which hides
|
---|
1531 | all host traffic from the VM's network adaptor, but allows
|
---|
1532 | it to see traffic from and to other VMs.
|
---|
1533 | </para>
|
---|
1534 | </listitem>
|
---|
1535 |
|
---|
1536 | <listitem>
|
---|
1537 | <para>
|
---|
1538 | <computeroutput>allow-all</computeroutput>, which removes
|
---|
1539 | all restrictions. The VM's network adaptor sees all
|
---|
1540 | traffic.
|
---|
1541 | </para>
|
---|
1542 | </listitem>
|
---|
1543 |
|
---|
1544 | </itemizedlist>
|
---|
1545 | </listitem>
|
---|
1546 |
|
---|
1547 | </itemizedlist>
|
---|
1548 |
|
---|
1549 | </sect1>
|
---|
1550 |
|
---|
1551 | </chapter>
|
---|