After stopping the tunnel, the included routes for the PacketTunnelProvider are not being cleared/removed

We have a PakcetTunnelProvider in SystemExtension with split tunnelling. We are setting up a private range of IP address (240.0.0.1/10) as include routes and a few match domains using NEPacketTunnelNetworkSettings. Everything works fine. We are able to setup tunnel settings and receive DNS as well as data traffic as per our rules.

However, when we execute the netstat -rn -f inet command in Terminal, it shows the following output:

240.0.0/10 link#8 UCS utun0

240.0.0.1 10.211.55.1 UGHS en0

240.0.0.2 10.211.55.1 UGHS en0

240.0.0.3 link#8 UHWIi utun0

After stopping the tunnel, some stale entries remain in the route table, as evidenced by the output of netstat -rn -f inet:

240.0.0/10 link#8 UCS utun0

240.0.0.3 link#8 UHWIi utun0

The expected behavior is that included routes should automatically clear once the tunnel stops.

** It's noteworthy that we've only observed this behaviour on Monterey OS; **

it works as expected on Ventura and Sonoma (where routes are automatically removed upon tunnel cessation)

We have tried to set the tunnel settings to nil explicitly, but no luck.

setTunnelNetworkSettings(nil) { _ in} 

We're unsure why the routes aren't clearing properly on Monterey OS.

Thanks -

Happy questioning

We're unsure why the routes aren't clearing properly on Monterey OS.

The most direct explanation is that this is a bug in macOS that was fixed in macOS 13.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

After stopping the tunnel, the included routes for the PacketTunnelProvider are not being cleared/removed
 
 
Q