VirtualBox

source: vbox/trunk/doc/manual/en_US/dita/topics/natforward.dita@ 99497

最後變更 在這個檔案從99497是 99497,由 vboxsync 提交於 2 年 前

manual: Split out the topics of converted manpages into separate files and generate ditamap files for each manpage to avoid needing to hardcode anything in UserManual.xml. This means that the topics inside a manpage can be supressed from the toc, but otoh, they get numbered (with 4.x). The per-topic files are named by refentry/refsect1/refsect2 @id and are currently not cleaned up by 'kmk clean'. bugref:10302

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 4.5 KB
 
1<?xml version='1.0' encoding='UTF-8'?>
2<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
3<topic xml:lang="en-us" id="natforward">
4 <title>Configuring Port Forwarding with NAT</title>
5
6 <body>
7 <p>
8 As the virtual machine is connected to a private network
9 internal to Oracle VM VirtualBox and invisible to the host, network
10 services on the guest are not accessible to the host machine or
11 to other computers on the same network. However, like a physical
12 router, Oracle VM VirtualBox can make selected services available to
13 the world outside the guest through <i>port
14 forwarding</i>. This means that Oracle VM VirtualBox listens to
15 certain ports on the host and resends all packets which arrive
16 there to the guest, on the same or a different port.
17 </p>
18 <p>
19 To an application on the host or other physical or virtual
20 machines on the network, it looks as though the service being
21 proxied is actually running on the host. This also means that
22 you cannot run the same service on the same ports on the host.
23 However, you still gain the advantages of running the service in
24 a virtual machine. For example, services on the host machine or
25 on other virtual machines cannot be compromised or crashed by a
26 vulnerability or a bug in the service, and the service can run
27 in a different operating system than the host system.
28 </p>
29 <p>
30 To configure port forwarding you can use the graphical
31 <b outputclass="bold">Port Forwarding</b> editor which
32 can be found in the <b outputclass="bold">Network</b>
33 settings dialog for network adaptors configured to use NAT.
34 Here, you can map host ports to guest ports to allow network
35 traffic to be routed to a specific port in the guest.
36 </p>
37 <p>
38 Alternatively, the command line tool
39 <userinput>VBoxManage</userinput> can be used. See
40 <xref href="vboxmanage-modifyvm.dita"/>.
41 </p>
42 <p>
43 You will need to know which ports on the guest the service uses
44 and to decide which ports to use on the host. You may want to
45 use the same ports on the guest and on the host. You can use any
46 ports on the host which are not already in use by a service. For
47 example, to set up incoming NAT connections to an
48 <userinput>ssh</userinput> server in the guest, use the following
49 command:
50 </p>
51 <pre xml:space="preserve">VBoxManage modifyvm "VM name" --nat-pf1 "guestssh,tcp,,2222,,22"</pre>
52 <p>
53 In the above example, all TCP traffic arriving on port 2222 on
54 any host interface will be forwarded to port 22 in the guest.
55 The protocol name <codeph>tcp</codeph> is a mandatory
56 attribute defining which protocol should be used for forwarding,
57 <codeph>udp</codeph> could also be used. The name
58 <codeph>guestssh</codeph> is purely descriptive and will be
59 auto-generated if omitted. The number after
60 <codeph>--nat-pf</codeph> denotes the network card, as with
61 other <userinput>VBoxManage</userinput> commands.
62 </p>
63 <p>
64 To remove this forwarding rule, use the following command:
65 </p>
66 <pre xml:space="preserve">VBoxManage modifyvm "VM name" --natpf1 delete "guestssh"</pre>
67 <p>
68 If for some reason the guest uses a static assigned IP address
69 not leased from the built-in DHCP server, it is required to
70 specify the guest IP when registering the forwarding rule, as
71 follows:
72 </p>
73 <pre xml:space="preserve">VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,10.0.2.19,22"</pre>
74 <p>
75 This example is identical to the previous one, except that the
76 NAT engine is being told that the guest can be found at the
77 10.0.2.19 address.
78 </p>
79 <p>
80 To forward <i>all</i> incoming traffic from a
81 specific host interface to the guest, specify the IP of that
82 host interface as follows:
83 </p>
84 <pre xml:space="preserve">VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,127.0.0.1,2222,,22"</pre>
85 <p>
86 This example forwards all TCP traffic arriving on the localhost
87 interface at 127.0.0.1 through port 2222 to port 22 in the
88 guest.
89 </p>
90 <p>
91 It is possible to configure incoming NAT connections while the
92 VM is running, see <xref href="vboxmanage-controlvm.dita"/>.
93 </p>
94 </body>
95
96</topic>
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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