10.0.0.0/24DHCP server on vport0
.
-Option 4 - VMs as real hosts on the same network
+Option 4 - VMs on the real network
-In this scenario, the VM interface will be attached to the same network as
-the host so it can be configured as if it were physically connected to the
-host network.
-This option only works for Ethernet-based devices, as the IEEE 802.11 standard
-prevents wireless interfaces from participating in network bridges.
+In this scenario, the VM interface will be bridged with the same
+network as the host. The VM can then be configured as if it were
+physically connected to the host network.
+This option only works for hosts with Ethernet connectivity, as the
+IEEE 802.11 standard prevents wireless interfaces from participating
+in network bridges.
-Create the bridge0
interface with the host network interface as a
-bridge port.
-In this example, the host network interface is em0
- you should
-substitute the interface name that you wish to connect the VM to:
+The Ethernet network will be switched between the real network, the
+host, and the VM using veb(4).
+Because veb(4) disconnects interfaces added as ports from the IP
+stack, any IP configuration on the real interface has to be moved
+to a vport(4) interface
+for the host to be able to participate in the network.
+In this example em0
is the interface connected to the
+real network.
+
+
+Move the IP configuration from em0
to vport0
:
-# echo 'add em0' > /etc/hostname.bridge0
-# sh /etc/netstart bridge0
+# mv /etc/hostname.em0 /etc/hostname.vport0
+# echo up >> /etc/hostname.vport0
+# echo up >> /etc/hostname.em0
+# sh /etc/netstart em0 vport0
+
+
+
+Create the veb0
interface and add the em0
+and vport0
interfacs:
+
+
+# cat <<END > /etc/hostname.veb0
+add em0
+add vport0
+up
+END
+# sh /etc/netstart veb0
As done in the previous example, create or modify the
@@ -312,7 +335,7 @@ that a virtual switch is defined:
switch "my_switch" {
- interface bridge0
+ interface veb0
}
vm "my_vm" {
@@ -321,15 +344,18 @@ vm "my_vm" {
}
-The my_vm
guest can now participate in the host network as if it
+The my_vm
guest can now participate on the real network as if it
were physically connected.
-Note: If the host interface (em0
in the above example) is
-also configured using DHCP,
-dhcpleased(8) running on that
-interface may block DHCP requests from reaching guest VMs.
-In this case, you should select a different host interface not using DHCP,
-or terminate any dhcpleased(8)
-processes assigned to that interface before starting VMs, or use static IP
-addresses for the VMs.
+Note: If the host interface (em0
in the above
+example) uses automatic address configuration (eg, DHCP), it may
+rely on the MAC address of the interface to get a particular IP
+address assigned. In this situation the MAC address from em0
+can be assigned to vport0
so it can use it on the real
+network.
+
+
+Virtual machines can be connected to a real network but isolated
+from the host by omitting the vport interface in the configuration
+above.