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="network_hostonly">
|
---|
4 | <title>Host-Only Networking</title>
|
---|
5 |
|
---|
6 | <body>
|
---|
7 | <p>
|
---|
8 | Host-only networking can be thought of as a hybrid between the
|
---|
9 | bridged and internal networking modes. As with bridged networking,
|
---|
10 | the virtual machines can talk to each other and the host as if
|
---|
11 | they were connected through a physical Ethernet switch. As with
|
---|
12 | internal networking, a physical networking interface need not be
|
---|
13 | present, and the virtual machines cannot talk to the world outside
|
---|
14 | the host since they are not connected to a physical networking
|
---|
15 | interface.
|
---|
16 | </p>
|
---|
17 | <p>
|
---|
18 | When host-only networking is used, Oracle VM VirtualBox creates a new
|
---|
19 | software interface on the host which then appears next to your
|
---|
20 | existing network interfaces. In other words, whereas with bridged
|
---|
21 | networking an existing physical interface is used to attach
|
---|
22 | virtual machines to, with host-only networking a new
|
---|
23 | <i>loopback</i> interface is created on the host.
|
---|
24 | And whereas with internal networking, the traffic between the
|
---|
25 | virtual machines cannot be seen, the traffic on the loopback
|
---|
26 | interface on the host can be intercepted.
|
---|
27 | </p>
|
---|
28 | <note>
|
---|
29 | <p>
|
---|
30 | Hosts running recent macOS versions do not support host-only
|
---|
31 | adapters. These adapters are replaced by host-only networks,
|
---|
32 | which define a network mask and an IP address range, where the
|
---|
33 | host network interface receives the lowest address in the range.
|
---|
34 | </p>
|
---|
35 | <p>
|
---|
36 | The host network interface gets added and removed dynamically by
|
---|
37 | the operating system, whenever a host-only network is used by
|
---|
38 | virtual machines.
|
---|
39 | </p>
|
---|
40 | <p>
|
---|
41 | On macOS hosts, choose the <b outputclass="bold">Host-Only
|
---|
42 | Network</b> option when configuring a network adapter.
|
---|
43 | The <b outputclass="bold">Host-Only Adapter</b> option is
|
---|
44 | provided for legacy support.
|
---|
45 | </p>
|
---|
46 | </note>
|
---|
47 | <p>
|
---|
48 | Host-only networking is particularly useful for preconfigured
|
---|
49 | virtual appliances, where multiple virtual machines are shipped
|
---|
50 | together and designed to cooperate. For example, one virtual
|
---|
51 | machine may contain a web server and a second one a database, and
|
---|
52 | since they are intended to talk to each other, the appliance can
|
---|
53 | instruct Oracle VM VirtualBox to set up a host-only network for the two.
|
---|
54 | A second, bridged, network would then connect the web server to
|
---|
55 | the outside world to serve data to, but the outside world cannot
|
---|
56 | connect to the database.
|
---|
57 | </p>
|
---|
58 | <p>
|
---|
59 | To enable a host-only network interface for a virtual machine, do
|
---|
60 | either of the following:
|
---|
61 | </p>
|
---|
62 | <ul>
|
---|
63 | <li>
|
---|
64 | <p>
|
---|
65 | Go to the <b outputclass="bold">Network</b> page in the
|
---|
66 | virtual machine's <b outputclass="bold">Settings</b>
|
---|
67 | dialog and select an <b outputclass="bold">Adapter</b>
|
---|
68 | tab. Ensure that the <b outputclass="bold">Enable Network
|
---|
69 | Adapter</b> check box is selected and choose
|
---|
70 | <b outputclass="bold">Host-Only Adapter</b> for the
|
---|
71 | <b outputclass="bold">Attached To</b> field.
|
---|
72 | </p>
|
---|
73 | </li>
|
---|
74 | <li>
|
---|
75 | <p>
|
---|
76 | On the command line, use <userinput>VBoxManage modifyvm
|
---|
77 | vmname --nic <varname>x</varname> hostonly</userinput>. See
|
---|
78 | <xref href="vboxmanage-modifyvm.dita"/>.
|
---|
79 | </p>
|
---|
80 | </li>
|
---|
81 | </ul>
|
---|
82 | <p>
|
---|
83 | For host-only networking, as with internal networking, you may
|
---|
84 | find the DHCP server useful that is built into Oracle VM VirtualBox.
|
---|
85 | This is enabled by default and manages the IP addresses in the
|
---|
86 | host-only network. Without the DHCP server you would need to
|
---|
87 | configure all IP addresses statically.
|
---|
88 | </p>
|
---|
89 | <ul>
|
---|
90 | <li>
|
---|
91 | <p>
|
---|
92 | In VirtualBox Manager you can configure the DHCP server by choosing
|
---|
93 | <b outputclass="bold">File</b>,
|
---|
94 | <b outputclass="bold">Tools</b>,
|
---|
95 | <b outputclass="bold">Network Manager</b>. The Network
|
---|
96 | Manager window lists all host-only networks which are
|
---|
97 | presently in use. Select the network name and then use the
|
---|
98 | <b outputclass="bold">DHCP Server</b> tab to configure
|
---|
99 | DHCP server settings. See <xref href="network-manager.dita#network-manager"/>.
|
---|
100 | </p>
|
---|
101 | </li>
|
---|
102 | <li>
|
---|
103 | <p>
|
---|
104 | Alternatively, you can use the <userinput>VBoxManage
|
---|
105 | dhcpserver</userinput> command. See
|
---|
106 | <xref href="vboxmanage-dhcpserver.dita"/>.
|
---|
107 | </p>
|
---|
108 | </li>
|
---|
109 | </ul>
|
---|
110 | <note>
|
---|
111 | <p>
|
---|
112 | On Linux and macOS hosts the number of host-only interfaces is
|
---|
113 | limited to 128. There is no such limit for Oracle Solaris and
|
---|
114 | Windows hosts.
|
---|
115 | </p>
|
---|
116 | </note>
|
---|
117 | <p>
|
---|
118 | On Linux, macOS and Solaris Oracle VM VirtualBox will only allow IP
|
---|
119 | addresses in 192.168.56.0/21 range to be assigned to host-only
|
---|
120 | adapters. For IPv6 only link-local addresses are allowed. If other
|
---|
121 | ranges are desired, they can be enabled by creating
|
---|
122 | <filepath>/etc/vbox/networks.conf</filepath> and specifying
|
---|
123 | allowed ranges there. For example, to allow 10.0.0.0/8 and
|
---|
124 | 192.168.0.0/16 IPv4 ranges as well as 2001::/64 range put the
|
---|
125 | following lines into <filepath>/etc/vbox/networks.conf</filepath>:
|
---|
126 | </p>
|
---|
127 | <pre xml:space="preserve"> * 10.0.0.0/8 192.168.0.0/16
|
---|
128 | * 2001::/64
|
---|
129 | </pre>
|
---|
130 | <p>
|
---|
131 | Lines starting with the hash <userinput>#</userinput> are ignored. The
|
---|
132 | following example allows any addresses, effectively disabling
|
---|
133 | range control:
|
---|
134 | </p>
|
---|
135 | <pre xml:space="preserve"> * 0.0.0.0/0 ::/0
|
---|
136 | </pre>
|
---|
137 | <p>
|
---|
138 | If the file exists, but no ranges are specified in it, no
|
---|
139 | addresses will be assigned to host-only adapters. The following
|
---|
140 | example effectively disables all ranges:
|
---|
141 | </p>
|
---|
142 | <pre xml:space="preserve"> # No addresses are allowed for host-only adapters
|
---|
143 | </pre>
|
---|
144 | </body>
|
---|
145 |
|
---|
146 | </topic>
|
---|