Understanding VM Networking

Understanding Anka VM networking

Prerequisites

  1. You've installed the Anka Virtualization package
  2. You've got an active license
  3. You've created your first VM Template
  4. You understand how to start and access your VM
  5. You grasp how to modify VM settings, like network-card

By default, we use Apple's VMNET interface for networking. We also configure the network service as “Using DHCP”.

Anka VMs, by default, use a shared networking configuration with the host. It’s a kind of NAT + DHCP. Every time you start/resume a VM, it gets assigned an IP that you can see with sudo anka show {vmNameOrUUID} command.

SSH access (“Remote Login”) is enabled by default on Anka VMs.

We provide a fixed IP inside of the VM for accessing the host: 192.168.64.1 (or 192.168.128.1 for “host” type).

Changing the network configuration for Anka VMs

> sudo anka modify 11.0.1 set network-card --help
Usage: anka modify set network-card [OPTIONS] [INDEX]...

  Modify network card settings

Options:
  -t, --type [shared|host|bridge|disconnected]
  -b, --bridge TEXT               host interface name to bridge with
  -m, --mac TEXT                  specify fixed MAC address
  -n, --no-mac                    deassign fixed MAC address
  -v, --vlan INTEGER              assign VLAN ID
  -c, --controller [anet|virtio-net]
                                  set controller
  --help                          Display usage information

WiFi interfaces are not supported yet

❯ anka describe 11.0.1
. . .
network_cards

+------------+--------+--------+-----------+
|   pci_slot | type   | mode   |    pci_id |
+============+========+========+===========+
|         28 | anet   | shared | 538975646 |
+------------+--------+--------+-----------+
. . .

❯ anka modify 11.0.1 set network-card 0 -t bridge

❯ anka describe 11.0.1
. . .
network_cards

+------------+--------+--------+-----------+
|   pci_slot | type   | mode   |    pci_id |
+============+========+========+===========+
|         28 | anet   | bridge | 538975646 |
+------------+--------+--------+-----------+
. . .
TypeDescription
sharedThe default network type operating as NAT + DHCP. Every VM after the start/resume gets an IP address assigned by the internal DHCP server in range 192.168.64.2 - 192.168.64.254. Programs inside a VM can access external networks (outside the host) and the internet directly. Also, other VMs on the host are also accessible.

To access ports/services on VMs using a shared network, enable [port forwarding](/docs/anka-virtualization/command-reference/#modify-templatename-add-port-forwarding) and connect to the host IP at the forwarded port.

hostIt is very similar to the shared one, but the VM get IP addresses from range 192.168.128.2 - 192.168.128.254 and can’t access external networks outside of the host.
bridgeThe Bridged type will cause the VM to show in the network as an individual device and receive a unique IP separate from the host.

VMs can be bridged to Ethernet interfaces only (including USB dongles). WiFi interfaces are not supported yet.

An ENV is available to set the interface name: `ANKA_BRIDGE_NAME=en0`

When using the bridge, port-forwarding is not necessary as the VM will receive a unique IP that will be accessible directly to all other devices on the network.

disconnectedThe VM will have a disconnected network cable.

Assigning a Static IP

Anka CLI version 2.2 and greater supports Static IP on VMs running on Catalina hosts (the guest OS can be any supported macOS version):

Static IP VM

MAC Addresses

Anka will dynamically assign MAC addresses to your VM. In Catalina and higher, you can assign custom MAC Addresses with the anka modify set network-card --mac option.

Be aware that if you clone your VM Template with a specific MAC, both VMs cannot run at the same time

Dynamic MAC Addresses are not guaranteed to be unique, though, reuse/collision is rare

In Mojave or older macOS versions: Even if a custom MAC is set, Apple's VMNET doesn't recognize it on the network outside of the VM. We do a translation from the custom MAC to the one VMNET assigns. This causes the external to VM network to see the VMNET MAC, but inside of the VM you'll see the custom MAC.


Last modified November 10, 2020 : troubleshooting + what's new + anka cp (c47f8d8) by Nathan Pierce