<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "dnssd",
  "identifier" : "/documentation/dnssd/kDNSServiceInterfaceIndexAny",
  "metadataVersion" : "0.1.0",
  "role" : "Global Variable",
  "symbol" : {
    "kind" : "Global Variable",
    "modules" : [
      "dnssd"
    ],
    "preciseIdentifier" : "c:@macro@kDNSServiceInterfaceIndexAny"
  },
  "title" : "kDNSServiceInterfaceIndexAny"
}
-->

# kDNSServiceInterfaceIndexAny

```
var kDNSServiceInterfaceIndexAny: Int32 { get }
```

## Discussion

Specific interface indexes are identified via a 32-bit unsigned integer returned by the if_nametoindex() family of calls.

If the client passes 0 for interface index, that means “do the right thing”, which (at present) means, “if the name is in an mDNS local multicast domain (e.g. ‘local.’, ‘254.169.in-addr.arpa.’, ‘{8,9,A,B}.E.F.ip6.arpa.’) then multicast on all applicable interfaces, otherwise send via unicast to the appropriate DNS server.” Normally, most clients will use 0 for interface index to automatically get the default sensible behaviour.

If the client passes a positive interface index, then that indicates to do the operation only on that one specified interface.

If the client passes [`kDNSServiceInterfaceIndexLocalOnly`](/documentation/dnssd/kDNSServiceInterfaceIndexLocalOnly) when registering a service, then that service will be found *only* by other local clients on the same machine that are browsing using [`kDNSServiceInterfaceIndexLocalOnly`](/documentation/dnssd/kDNSServiceInterfaceIndexLocalOnly) or [`kDNSServiceInterfaceIndexAny`](/documentation/dnssd/kDNSServiceInterfaceIndexAny). If a client has a ‘private’ service, accessible only to other processes running on the same machine, this allows the client to advertise that service in a way such that it does not inadvertently appear in service lists on all the other machines on the network.

If the client passes [`kDNSServiceInterfaceIndexLocalOnly`](/documentation/dnssd/kDNSServiceInterfaceIndexLocalOnly) when browsing then it will find *all* records registered on that same local machine. Clients explicitly wishing to discover *only* LocalOnly services can accomplish this by inspecting the interfaceIndex of each service reported to their [`DNSServiceBrowseReply`](/documentation/dnssd/DNSServiceBrowseReply) callback function, and discarding those where the interface index is not [`kDNSServiceInterfaceIndexLocalOnly`](/documentation/dnssd/kDNSServiceInterfaceIndexLocalOnly).

[`kDNSServiceInterfaceIndexP2P`](/documentation/dnssd/kDNSServiceInterfaceIndexP2P) is meaningful only in Browse, QueryRecord, Register, and Resolve operations. It should not be used in other DNSService APIs.

- If [`kDNSServiceInterfaceIndexP2P`](/documentation/dnssd/kDNSServiceInterfaceIndexP2P) is passed to [`DNSServiceBrowse(_:_:_:_:_:_:_:)`](/documentation/dnssd/DNSServiceBrowse(_:_:_:_:_:_:_:)) or [`DNSServiceQueryRecord(_:_:_:_:_:_:_:_:)`](/documentation/dnssd/DNSServiceQueryRecord(_:_:_:_:_:_:_:_:)), it restricts the operation to P2P.
- If kDNSServiceInterfaceIndexP2P is passed to DNSServiceRegister, it is mapped internally to kDNSServiceInterfaceIndexAny with the kDNSServiceFlagsIncludeP2P set.
- If [`kDNSServiceInterfaceIndexP2P`](/documentation/dnssd/kDNSServiceInterfaceIndexP2P) is passed to [`DNSServiceResolve(_:_:_:_:_:_:_:_:)`](/documentation/dnssd/DNSServiceResolve(_:_:_:_:_:_:_:_:)), it is mapped internally to [`kDNSServiceInterfaceIndexAny`](/documentation/dnssd/kDNSServiceInterfaceIndexAny) with the kDNSServiceFlagsIncludeP2P set, because resolving a P2P service may create and/or enable an interface whose index is not known a priori. The resolve callback will indicate the index of the interface via which the service can be accessed.

If applications pass [`kDNSServiceInterfaceIndexAny`](/documentation/dnssd/kDNSServiceInterfaceIndexAny) to [`DNSServiceBrowse(_:_:_:_:_:_:_:)`](/documentation/dnssd/DNSServiceBrowse(_:_:_:_:_:_:_:)) or [`DNSServiceQueryRecord(_:_:_:_:_:_:_:_:)`](/documentation/dnssd/DNSServiceQueryRecord(_:_:_:_:_:_:_:_:)), they must set the kDNSServiceFlagsIncludeP2P flag to include P2P. In this case, if a service instance or the record being queried is found over P2P, the resulting ADD event will indicate [`kDNSServiceInterfaceIndexP2P`](/documentation/dnssd/kDNSServiceInterfaceIndexP2P) as the interface index.

---

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)