<!--
{
  "availability" : [
    "macCatalyst: 13.0 -",
    "macOS: 10.10 -"
  ],
  "documentType" : "symbol",
  "framework" : "vmnet",
  "identifier" : "/documentation/vmnet",
  "metadataVersion" : "0.1.0",
  "role" : "Framework",
  "symbol" : {
    "kind" : "Framework",
    "modules" : [
      "vmnet"
    ],
    "preciseIdentifier" : "vmnet"
  },
  "title" : "vmnet"
}
-->

# vmnet

Connect with network interfaces to read and write packets on guest operating systems.

## Overview

The vmnet framework is an API for virtual machines to read and write packets.

The API allows a Guest OS interface to be in host mode or shared mode. Interfaces in host mode can communicate with the native host system and other interfaces running in host mode. In shared mode, the network interface can send and receive packets to the Internet, the native host, and other interfaces running in sharing mode.

> Note: For more information about virtualization technologies, see the <doc://com.apple.documentation/documentation/Hypervisor> framework.

### Requirements

The vmnet framework has the following requirements:

#### Entitlements

A sandboxed user space process must have the <doc://com.apple.documentation/documentation/BundleResources/Entitlements/com.apple.vm.networking> entitlement in order to use the vmnet API.

### Architecture

![](images/com.apple.vmnet/media-2557515@2x.png)

The VM Network API provides support for an interface in the guest operating system. The API provides the MAC address and MTU that you need to be configure on the guest OS interface. The interface receives a private IPv4 address via DHCP. IPv4 traffic originating from the guest operating system must use the private IPv4 address. The system drops packets sent from a different IPv4 address.

You can create a maximum of 32 interfaces with a limit of 4 per guest operating system. Each read or write call allows up to 200 packets to be read or written for a maximum of 256KB. Each packet written needs to be a complete ethernet frame.

## Topics

### Essentials

  <doc://com.apple.documentation/documentation/BundleResources/Entitlements/com.apple.vm.networking>

### Creating a network configuration

[`func vmnet_network_create(vmnet_network_configuration_ref, UnsafeMutablePointer<vmnet_return_t>?) -> vmnet_network_ref?`](/documentation/vmnet/vmnet_network_create(_:_:))

Creates a vmnet network based on the provided configuration.

[`func vmnet_network_configuration_create(vmnet_mode_t, UnsafeMutablePointer<vmnet_return_t>?) -> vmnet_network_configuration_ref?`](/documentation/vmnet/vmnet_network_configuration_create(_:_:))

Creates a network configuration object with the specified operating mode.

[`func vmnet_network_create_with_serialization(xpc_object_t, UnsafeMutablePointer<vmnet_return_t>?) -> vmnet_network_ref?`](/documentation/vmnet/vmnet_network_create_with_serialization(_:_:))

Creates a vmnet network from an XPC object you obtained from calling the vmnet networkcopy serialization API.

[`func vmnet_network_copy_serialization(vmnet_network_ref, UnsafeMutablePointer<vmnet_return_t>?) -> xpc_object_t?`](/documentation/vmnet/vmnet_network_copy_serialization(_:_:))

Serializes a vmnet network to an XPC object.

### Starting and stopping interfaces

[`func vmnet_start_interface(xpc_object_t, dispatch_queue_t, vmnet_start_interface_completion_handler_t) -> interface_ref?`](/documentation/vmnet/vmnet_start_interface(_:_:_:))

Starts a new virtual interface instance.

[`func vmnet_interface_start_with_network(vmnet_network_ref, xpc_object_t, dispatch_queue_t, vmnet_start_interface_completion_handler_t) -> interface_ref?`](/documentation/vmnet/vmnet_interface_start_with_network(_:_:_:_:))

Starts a new virtual interface instance on a network.

[`func vmnet_interface_set_event_callback(interface_ref, interface_event_t, dispatch_queue_t?, vmnet_interface_event_callback_t?) -> vmnet_return_t`](/documentation/vmnet/vmnet_interface_set_event_callback(_:_:_:_:))

Schedules a callback to be executed when events for the specified interface are received.

[`func vmnet_stop_interface(interface_ref, dispatch_queue_t, vmnet_interface_completion_handler_t) -> vmnet_return_t`](/documentation/vmnet/vmnet_stop_interface(_:_:_:))

Stops I/O on the virtual interface.

### Customizing a network configuration

[`typealias vmnet_network_configuration_ref`](/documentation/vmnet/vmnet_network_configuration_ref)

A reference to a network vmnet network configuration.

[`func vmnet_network_configuration_add_dhcp_reservation(vmnet_network_configuration_ref, UnsafePointer<ether_addr_t>, UnsafePointer<in_addr>) -> vmnet_return_t`](/documentation/vmnet/vmnet_network_configuration_add_dhcp_reservation(_:_:_:))

Configures a new dhcp reservation for a vmnet network.

[`func vmnet_network_configuration_add_port_forwarding_rule(vmnet_network_configuration_ref, UInt8, sa_family_t, UInt16, UInt16, UnsafeRawPointer) -> vmnet_return_t`](/documentation/vmnet/vmnet_network_configuration_add_port_forwarding_rule(_:_:_:_:_:_:))

Configures a new port forwarding rule for a vmnet network.

[`func vmnet_network_configuration_disable_router_advertisement(vmnet_network_configuration_ref)`](/documentation/vmnet/vmnet_network_configuration_disable_router_advertisement(_:))

Disables router advertisement on a network.

[`func vmnet_network_configuration_disable_nat66(vmnet_network_configuration_ref)`](/documentation/vmnet/vmnet_network_configuration_disable_nat66(_:))

Disables NAT66 on a network.

[`func vmnet_network_configuration_disable_nat44(vmnet_network_configuration_ref)`](/documentation/vmnet/vmnet_network_configuration_disable_nat44(_:))

Disables NAT44 on a network.

[`func vmnet_network_configuration_disable_dns_proxy(vmnet_network_configuration_ref)`](/documentation/vmnet/vmnet_network_configuration_disable_dns_proxy(_:))

Disables the DNS proxy on a network.

[`func vmnet_network_configuration_disable_dhcp(vmnet_network_configuration_ref)`](/documentation/vmnet/vmnet_network_configuration_disable_dhcp(_:))

Disables DHCP server on a network.

[`let vmnet_nat66_prefix_length_key: UnsafePointer<CChar>`](/documentation/vmnet/vmnet_nat66_prefix_length_key)

The IPv6 prefix (uint64) to use with vmnet shared mode.

[`let vmnet_nat66_prefix_key: UnsafePointer<CChar>`](/documentation/vmnet/vmnet_nat66_prefix_key)

The IPv6 prefix string to use with vmnet shared mode.

[`func vmnet_port_forwarding_rule_get_details(xpc_object_t, UnsafeMutablePointer<UInt8>, UnsafeMutablePointer<UInt16>, UnsafeMutablePointer<in_addr>, UnsafeMutablePointer<UInt16>) -> vmnet_return_t`](/documentation/vmnet/vmnet_port_forwarding_rule_get_details(_:_:_:_:_:))

Extracts port forwarding rule details from the rule XPC dictionary object.

[`func vmnet_network_configuration_set_external_interface(vmnet_network_configuration_ref, UnsafePointer<CChar>) -> vmnet_return_t`](/documentation/vmnet/vmnet_network_configuration_set_external_interface(_:_:))

Configures the external interface of a vmnet network.

[`func vmnet_network_configuration_set_ipv4_subnet(vmnet_network_configuration_ref, UnsafePointer<in_addr>, UnsafePointer<in_addr>) -> vmnet_return_t`](/documentation/vmnet/vmnet_network_configuration_set_ipv4_subnet(_:_:_:))

Configures the IPv4 addresses of a vmnet network.

[`func vmnet_network_configuration_set_ipv6_prefix(vmnet_network_configuration_ref, UnsafePointer<in6_addr>, UInt8) -> vmnet_return_t`](/documentation/vmnet/vmnet_network_configuration_set_ipv6_prefix(_:_:_:))

Configures the IPv6 prefix for a vmnet network object.

[`func vmnet_network_configuration_set_mtu(vmnet_network_configuration_ref, UInt32) -> vmnet_return_t`](/documentation/vmnet/vmnet_network_configuration_set_mtu(_:_:))

Configures the maximum transmission unit (MTU) for a vmnet network.

[`func vmnet_network_get_ipv6_prefix(vmnet_network_ref, UnsafeMutablePointer<in6_addr>, UnsafeMutablePointer<UInt8>)`](/documentation/vmnet/vmnet_network_get_ipv6_prefix(_:_:_:))

Returns the IPv6 prefix of a network.

[`func vmnet_network_get_ipv4_subnet(vmnet_network_ref, UnsafeMutablePointer<in_addr>, UnsafeMutablePointer<in_addr>)`](/documentation/vmnet/vmnet_network_get_ipv4_subnet(_:_:_:))

Returns the IPv4 subnet of a network.

### Reading and Writing Packets

[`func vmnet_read(interface_ref, UnsafeMutablePointer<vmpktdesc>, UnsafeMutablePointer<Int32>) -> vmnet_return_t`](/documentation/vmnet/vmnet_read(_:_:_:))

Attempts to read a specified number of packets from an interface.

[`func vmnet_write(interface_ref, UnsafeMutablePointer<vmpktdesc>, UnsafeMutablePointer<Int32>) -> vmnet_return_t`](/documentation/vmnet/vmnet_write(_:_:_:))

Attempts to write specified packets to an interface.

### Data types

[`enum vmnet_return_t`](/documentation/vmnet/vmnet_return_t)

Values returned by functions in the vmnet Framework.

[`struct vmpktdesc`](/documentation/vmnet/vmpktdesc)

Describes a packet.

[`typealias interface_ref`](/documentation/vmnet/interface_ref)

A virtual network interface.

[`struct interface_event_t`](/documentation/vmnet/interface_event_t)

Interface event types.

[`enum operating_modes_t`](/documentation/vmnet/operating_modes_t)

The operating modes for an interface.

[`typealias vmnet_mode_t`](/documentation/vmnet/vmnet_mode_t)

A type that defines the operating modes of the vmnet interface.

[`typealias vmnet_network_ref`](/documentation/vmnet/vmnet_network_ref)

A pointer to a network structure.

### Constants

[interface_desc XPC Dictionary Keys](/documentation/vmnet/interface_desc_xpc_dictionary_keys)

XPC dictionary keys supported by the `interface_desc` parameter passed to the `vmnet` function to describe the parameters of the network interface.

[interface_param XPC Dictionary Keys](/documentation/vmnet/interface_param_xpc_dictionary_keys)

XPC dictionary keys used by the `interface_param` argument returned by the completion handler of the `vmnet` function that describes the parameters that should be used to configure the network interface.

[event XPC Dictionary](/documentation/vmnet/event_xpc_dictionary)

XPC dictionary keys used by the `event` value returned to the client in the `handler` callback specified by the `vmnet` function that provides information about the callback event.

### Reference

[vmnet Constants](/documentation/vmnet/vmnet_constants)

[vmnet Functions](/documentation/vmnet/vmnet_functions)

[vmnet Data Types](/documentation/vmnet/vmnet_data_types)

### Variables

[`let vmnet_enable_virtio_header_key: UnsafePointer<CChar>`](/documentation/vmnet/vmnet_enable_virtio_header_key-swift.var)

Enable virtio headers in all packets.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)