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

# NENetworkRule

A rule to match attributes of network traffic.

```
class NENetworkRule
```

## Topics

### Creating a network rule

[`-  initWithDestinationNetwork:prefix:protocol:`](/documentation/NetworkExtension/NENetworkRule/init(destinationNetwork:prefix:protocol:))

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

[`-  initWithDestinationHost:protocol:`](/documentation/NetworkExtension/NENetworkRule/init(destinationHost:protocol:))

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

[`-  initWithRemoteNetwork:remotePrefix:localNetwork:localPrefix:protocol:direction:`](/documentation/NetworkExtension/NENetworkRule/init(remoteNetwork:remotePrefix:localNetwork:localPrefix:protocol:direction:))

Creates a rule that matches traffic by remote network, local network, protocol, and direction.

### Matching network traffic characteristics

[`matchRemoteEndpoint`](/documentation/NetworkExtension/NENetworkRule/matchRemoteEndpoint)

The remote endpoint that the rule matches.

[`matchRemotePrefix`](/documentation/NetworkExtension/NENetworkRule/matchRemotePrefix)

A number that specifies the remote sub-network that the rule matches.

[`matchLocalNetwork`](/documentation/NetworkExtension/NENetworkRule/matchLocalNetwork)

The local network that the rule matches.

[`matchLocalPrefix`](/documentation/NetworkExtension/NENetworkRule/matchLocalPrefix)

A number that specifies the local sub-network that the rule matches.

[`matchProtocol`](/documentation/NetworkExtension/NENetworkRule/matchProtocol)

The protocol that the rule matches.

[`Protocol`](/documentation/NetworkExtension/NENetworkRule/Protocol)

A type to represent network protocols used by routing rules.

[`matchDirection`](/documentation/NetworkExtension/NENetworkRule/matchDirection)

The direction of network traffic that the rule matches.

[`NETrafficDirection`](/documentation/NetworkExtension/NETrafficDirection)

A type to represent the direction of network traffic.

## Relationships

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`Hashable`](/documentation/Swift/Hashable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`NSCoding`](/documentation/Foundation/NSCoding)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)