<!--
{
  "availability" : [
    "macOS: 10.15.0 - 15.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "NetworkExtension",
  "identifier" : "/documentation/NetworkExtension/NENetworkRule/init(destinationNetwork:prefix:protocol:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Network Extension"
    ],
    "preciseIdentifier" : "c:objc(cs)NENetworkRule(im)initWithDestinationNetwork:prefix:protocol:"
  },
  "title" : "init(destinationNetwork:prefix:protocol:)"
}
-->

# init(destinationNetwork:prefix:protocol:)

Creates a rule that matches network traffic destined for a host within a specific network.

```
init(destinationNetwork networkEndpoint: NWHostEndpoint, prefix destinationPrefix: Int, protocol: NENetworkRule.Protocol)
```

## Parameters

`networkEndpoint`

An endpoint instance that matches the port and address or network that the rule matches. This endpoint must contain an address, not a hostname.

`destinationPrefix`

An integer that in combination with the address in the endpoint specifies the destination network that the rule matches.

`protocol`

The protocol that the rule matches.

## Discussion

If the port string of `networkEndpoint` is `0` or the empty string, the rule matches traffic on any port destined for the given address or network.

---

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)