Use OpenVPN trick to retain default gateway
Override default gateway with 2 split routes. - IPv4: 0.0.0.0/1, 128.0.0.0/1 - IPv6: 2000::/4, 3000::/4
This commit is contained in:
parent
a047d2bdd5
commit
7d26323d3f
|
@ -538,9 +538,14 @@ extension TunnelKitProvider: SessionProxyDelegate {
|
|||
|
||||
// route all traffic to VPN?
|
||||
if routingPolicies?.contains(.IPv4) ?? false {
|
||||
let defaultRoute = NEIPv4Route.default()
|
||||
defaultRoute.gatewayAddress = ipv4.defaultGateway
|
||||
routes.append(defaultRoute)
|
||||
// let defaultRoute = NEIPv4Route.default()
|
||||
// defaultRoute.gatewayAddress = ipv4.defaultGateway
|
||||
// routes.append(defaultRoute)
|
||||
for network in ["0.0.0.0", "128.0.0.0"] {
|
||||
let route = NEIPv4Route(destinationAddress: network, subnetMask: "128.0.0.0")
|
||||
route.gatewayAddress = ipv4.defaultGateway
|
||||
routes.append(route)
|
||||
}
|
||||
}
|
||||
|
||||
for r in ipv4.routes {
|
||||
|
@ -560,9 +565,14 @@ extension TunnelKitProvider: SessionProxyDelegate {
|
|||
|
||||
// route all traffic to VPN?
|
||||
if routingPolicies?.contains(.IPv6) ?? false {
|
||||
let defaultRoute = NEIPv6Route.default()
|
||||
defaultRoute.gatewayAddress = ipv6.defaultGateway
|
||||
routes.append(defaultRoute)
|
||||
// let defaultRoute = NEIPv6Route.default()
|
||||
// defaultRoute.gatewayAddress = ipv6.defaultGateway
|
||||
// routes.append(defaultRoute)
|
||||
for network in ["2000::", "3000::"] {
|
||||
let route = NEIPv6Route(destinationAddress: network, networkPrefixLength: 4)
|
||||
route.gatewayAddress = ipv6.defaultGateway
|
||||
routes.append(route)
|
||||
}
|
||||
}
|
||||
|
||||
for r in ipv6.routes {
|
||||
|
|
Loading…
Reference in New Issue