NETransparentProxyProvider can't process port 53 specifically for some reason (I don't see a technical reason it shouldn't), but it seems to work (i.e. catch UDP 53 traffic) when you don't specify a port:
NENetworkRule(remoteNetwork: nil, remotePrefix: 0, localNetwork: nil, localPrefix: 0, protocol: .UDP, direction: .outbound)
You can then ignore everything you are not interested in filtering:
override func handleNewUDPFlow(_ flow: NEAppProxyUDPFlow, initialRemoteEndpoint: NWEndpoint) -> Bool {
if let endpoint = initialRemoteEndpoint as? NWHostEndpoint {
if endpoint.port == "53" {
// Do the filtering
} else {
return false // Let OS handle it
}
}
}
Beware of this bug though. I'm not sure if it has been resolved yet.
Topic:
App & System Services
SubTopic:
Networking
Tags: