IPsec with Strongswan for MacOS/iOS native client

I’m trying since a few hours to get a new VPN setup to work. The idea is to have a gateway at a cloud provider that can collect traffic (as I can assume that a cloud provider will have better peerings than my local ISP) and then route that traffic back to my home over another IPsec tunnel and let it go out there using the cloud provider’s transport infrastructure.

Routing would then be made through OSPF in a separate VRF for IPsec. The tunnels will be IPv6 only (at least, that’s how I would like it to be) and use a clat client to translate it to v4 on the absolute last hop. Somehow, that’s the easy part.

The hard part is getting those tunnels able to go up on damn Apple stuff.

Currently, the ipsec.conf file I have on my server is :

conn ikev2-ipv6-clat
    auto=add
    compress=no
    type=tunnel
    keyexchange=ikev2
    mobike=yes
    fragmentation=yes

    left=%any
    leftid=@<fqdn_of_the_server>
    leftcert=/etc/letsencrypt/archive/<fqdn_of_the_server>/fullchain1.pem
    leftsubnet=::/0
    leftauth=pubkey
    leftsendcert=always

    right=%any
    rightid=%any
    rightsourceip=fd42:42:42::/64 #will be changed with a /64 of home and then routed through OSPFv3 when the tunnel goes up
    rightdns=2606:4700:4700::64,2606:4700:4700::6400            # Temporary cloudflare DNS64 servers. Will be replaced by own recursive resolvers when tunnel part is Ok
    rightauth=pubkey
    eap_identity=%any

    ike=aes256gcm16-prfsha256-ecp256,aes256gcm16-prfsha256-modp2048,aes256-sha2_256-modp2048!
    esp=aes256gcm16-ecp256,aes256gcm16-modp2048,aes256-sha2_256!

When mounting the tunnel on Mac OS in the native IKEv2 client, the logs I get on server side end up like this while the client is hanging without any information :

Jun  1 01:32:47 05[CFG] added configuration 'ikev2-ipv6-clat'
Jun  1 01:32:56 03[ENC]   parsing rule 0 IKE_SPI
Jun  1 01:32:56 03[ENC]   parsing rule 1 IKE_SPI
Jun  1 01:32:56 03[ENC] parsed a IKE_SA_INIT request header
Jun  1 01:32:56 07[MGR] checkout IKEv2 SA by message with SPIs f97d789b6b047c3a_i 0000000000000000_r
Jun  1 01:32:56 07[MGR] created IKE_SA (unnamed)[1]
Jun  1 01:32:56 07[ENC] <1> parsed IKE_SA_INIT request 0 [ SA KE No N(REDIR_SUP) N(NATD_S_IP) N(NATD_D_IP) N(FRAG_SUP) ]
Jun  1 01:32:56 07[CFG] <1> looking for an IKEv2 config for <IPv6 ADDRESSES>
Jun  1 01:32:56 07[CFG] <1> found matching ike config: %any...%any with prio 28
Jun  1 01:32:56 07[IKE] <1> local endpoint changed from 0.0.0.0[500] to <IPv6 ADDRESSES>[500]
Jun  1 01:32:56 07[IKE] <1> remote endpoint changed from 0.0.0.0 to <IPv6 ADDRESSES>[500]
Jun  1 01:32:56 07[IKE] <1> <IPv6 ADDRESSES> is initiating an IKE_SA
Jun  1 01:32:56 07[IKE] <1> IKE_SA (unnamed)[1] state change: CREATED => CONNECTING
Jun  1 01:32:56 07[CFG] <1> received proposals: IKE:AES_GCM_16_256/PRF_HMAC_SHA2_256/ECP_256, IKE:AES_GCM_16_256/PRF_HMAC_SHA2_256/MODP_2048, IKE:AES_CBC_256/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/ECP_256, IKE:AES_CBC_256/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_2048
Jun  1 01:32:56 07[CFG] <1> configured proposals: IKE:AES_GCM_16_256/PRF_HMAC_SHA2_256/ECP_256, IKE:AES_GCM_16_256/PRF_HMAC_SHA2_256/MODP_2048, IKE:AES_CBC_256/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_2048
Jun  1 01:32:56 07[CFG] <1> selected proposal: IKE:AES_GCM_16_256/PRF_HMAC_SHA2_256/ECP_256
Jun  1 01:32:56 07[IKE] <1> sending cert request for "CN=<FQDN_OF_THE_SERVER>"
Jun  1 01:32:56 07[ENC] <1> generating IKE_SA_INIT response 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) CERTREQ N(FRAG_SUP) N(CHDLESS_SUP) N(MULT_AUTH) ]
Jun  1 01:32:56 07[ENC] <1>   generating rule 0 IKE_SPI
Jun  1 01:32:56 07[ENC] <1>   generating rule 1 IKE_SPI
Jun  1 01:32:56 07[MGR] <1> checkin IKEv2 SA (unnamed)[1] with SPIs f97d789b6b047c3a_i cb27e93e66b38a8b_r
Jun  1 01:32:56 07[MGR] <1> checkin of IKE_SA successful
Jun  1 01:32:56 03[ENC]   parsing rule 0 IKE_SPI
Jun  1 01:32:56 03[ENC]   parsing rule 1 IKE_SPI
Jun  1 01:32:56 03[ENC] parsed a IKE_AUTH request header
Jun  1 01:32:56 08[MGR] checkout IKEv2 SA by message with SPIs f97d789b6b047c3a_i cb27e93e66b38a8b_r
Jun  1 01:32:56 08[MGR] IKE_SA (unnamed)[1] successfully checked out
Jun  1 01:32:56 08[ENC] <1> parsed IKE_AUTH request 1 [ IDi N(INIT_CONTACT) IDr CPRQ(ADDR MASK DHCP DNS ADDR6 DHCP6 DNS6 DOMAIN) N(ESP_TFC_PAD_N) N(NON_FIRST_FRAG) SA TSi TSr N(MOBIKE_SUP) N(EAP_ONLY) ]
Jun  1 01:32:56 08[IKE] <1> installing new virtual IP (family not supported)
tail: /var/log/strongswan.log: file truncated
Jun  1 01:33:01 00[DMN] Starting IKE charon daemon (strongSwan 5.9.8, Linux 6.1.0-37-arm64, aarch64)
Jun  1 01:33:01 05[CFG] received stroke: add connection 'ikev2-ipv6-clat'
Jun  1 01:33:01 05[CFG] conn ikev2-ipv6-clat
Jun  1 01:33:01 05[CFG]   ike=aes256gcm16-prfsha256-ecp256,aes256gcm16-prfsha256-modp2048,aes256-sha2_256-modp2048!
Jun  1 01:33:01 05[CFG]   keyexchange=ikev2
Jun  1 01:33:01 05[CFG] added configuration 'ikev2-ipv6-clat'
Jun  1 01:33:03 03[ENC]   parsing rule 0 IKE_SPI
Jun  1 01:33:03 03[ENC]   parsing rule 1 IKE_SPI
Jun  1 01:33:03 03[ENC] parsed a IKE_AUTH request header
Jun  1 01:33:03 07[MGR] checkout IKEv2 SA by message with SPIs f97d789b6b047c3a_i cb27e93e66b38a8b_r
Jun  1 01:33:03 07[MGR] IKE_SA checkout not successful

Apple Logs aren’t more helpful either

2025-06-01 03:18:17.771894+0200 0xd05bed   Default     0x0                  91175  0    NEIKEv2Provider: (NetworkExtension) [com.apple.networkextension:] Resetting IKEv2Session[1, C50AB4CC32A45F6C-7E7436707BE9EB75]
2025-06-01 03:18:17.771909+0200 0xd05bed   Default     0x0                  91175  0    NEIKEv2Provider: (NetworkExtension) [com.apple.networkextension:] Aborting session IKEv2Session[1, C50AB4CC32A45F6C-7E7436707BE9EB75]
2025-06-01 03:18:17.772032+0200 0xd05bed   Default     0x0                  91175  0    NEIKEv2Provider: (NetworkExtension) [com.apple.networkextension:] IKEv2Session[1, C50AB4CC32A45F6C-7E7436707BE9EB75] KernelSASession[1, IKEv2 Session Database] Uninstalling all child SAs
2025-06-01 03:18:17.772201+0200 0xd05bee   Default     0x0                  91175  0    NEIKEv2Provider: (NetworkExtension) [com.apple.networkextension:] Tearing down ipsec0
2025-06-01 03:18:17.772543+0200 0xd05bed   Default     0x0                  91175  0    NEIKEv2Provider: (NetworkExtension) [com.apple.networkextension:] Invalidating transports for IKEv2IKESA[1.1, C50AB4CC32A45F6C-7E7436707BE9EB75]
2025-06-01 03:18:17.772569+0200 0xd05bed   Default     0x0                  91175  0    NEIKEv2Provider: (NetworkExtension) [com.apple.networkextension:] Cancelling client C50AB4CC32A45F6C for <NEIKEv2Transport> UDP <SOME_IPV6> -> <SOME_IPV6>.500
2025-06-01 03:18:17.772892+0200 0xd05bed   Default     0x0                  91175  0    NEIKEv2Provider: (NetworkExtension) [com.apple.networkextension:] <NEIKEv2Transport> UDP <SOME_IPV6>.500 -> <SOME_IPV6>.500 out of clients, invalidating
2025-06-01 03:18:17.772950+0200 0xd05bed   Default     0x0                  91175  0    NEIKEv2Provider: (NetworkExtension) [com.apple.networkextension:] Cancelling client C50AB4CC32A45F6C for <NEIKEv2Transport> UDP NAT-T <SOME_IPV6>.4500 -> <SOME_IPV6>.4500
2025-06-01 03:18:17.773006+0200 0xd05bed   Default     0x0                  91175  0    NEIKEv2Provider: (NetworkExtension) [com.apple.networkextension:] <NEIKEv2Transport> UDP NAT-T <SOME_IPV6>.4500 -> <SOME_IPV6>.4500 out of clients, invalidating
2025-06-01 03:18:17.773129+0200 0xd05bed   Default     0x0                  91175  0    NEIKEv2Provider: (NetworkExtension) [com.apple.networkextension:] IKEv2Session[1, 6F092B52A6C1B279-0000000000000000] KernelSASession[1, IKEv2 Session Database] Uninstalling all child SAs
2025-06-01 03:18:17.773173+0200 0xd05bed   Default     0x0                  91175  0    NEIKEv2Provider: (NetworkExtension) [com.apple.networkextension:] Tearing down ipsec0
2025-06-01 03:18:17.773271+0200 0xd05bed   Default     0x0                  91175  0    NEIKEv2Provider: (NetworkExtension) [com.apple.networkextension:] <NEIPSecDB 0x9fe0f05b0 [0x207fec998]> {UniqueIndex = 1} invalidating
2025-06-01 03:18:17.773430+0200 0xd05bed   Error       0x0                  91175  0    NEIKEv2Provider: (NetworkExtension) [com.apple.networkextension:] Connection receive error Connection refused for <NEIKEv2Transport> UDP NAT-T <SOME_IPV6>.4500 -> <SOME_IPV6>.4500 (Closed)
2025-06-01 03:18:17.771934+0200 0xd04f45   Default     0x0                  555    0    nesessionmanager: [com.apple.networkextension:] NESMIKEv2VPNSession[Primary Tunnel:<FQDN OF THE SERVER>:8B711AB5-8ABB-4319-A95F-117F3F5818BD:(null)] in state NESMVPNSessionStateStopping: plugin set status to disconnected
2025-06-01 03:18:17.771948+0200 0xd04f45   Default     0x0                  555    0    nesessionmanager: [com.apple.networkextension:] NESMIKEv2VPNSession[Primary Tunnel:<FQDN OF THE SERVER>:8B711AB5-8ABB-4319-A95F-117F3F5818BD:(null)] in state NESMVPNSessionStateStopping: disposing all plugins
2025-06-01 03:18:17.771962+0200 0xd04f45   Default     0x0                  555    0    nesessionmanager: [com.apple.networkextension:] NESMIKEv2VPNSession[Primary Tunnel:<FQDN OF THE SERVER>:8B711AB5-8ABB-4319-A95F-117F3F5818BD:(null)]: Leaving state NESMVPNSessionStateStopping
2025-06-01 03:18:17.771981+0200 0xd04f45   Default     0x0                  555    0    nesessionmanager: [com.apple.networkextension:] NESMIKEv2VPNSession[Primary Tunnel:<FQDN OF THE SERVER>:8B711AB5-8ABB-4319-A95F-117F3F5818BD:(null)]: Entering state NESMVPNSessionStateDisposing, timeout 5 seconds

At this point, I’m in for so long that i have no idea where to look anymore. Things that stand out to me are the fact that the server is unable to assign IP’s for some reason and the fact that the client says that there is a NAT problem (which is running over native IPv6… So I really don’t see where the so called “NAT problem” could be).

Any idea? At this point, anything is good…

1 Like

Have you considered using WireGuard without the cloud gateway? It’s so much easier for a road warrior setup. Or it’s there a specific reason why you want to use IPsec?

Don’t assume, you can have a Wireguard road warrior setup up and running in 5 Minutes. Test it, if you are unhappy we can look into that.

One of many install scripts:

Or if you like docker and want a UI:

Setup ddns, port forwarding and you are ready. Pure IPv6 with NAT64 / DNS64, would be possible. But for the test I would use IPv4 for simplicity (Most guides don’t bother with IPv6).

1 Like

I have thought about wireguard. At this point, I have a OpenVPN setup without cloud gateway. The cloud gateway has the unique purporse to use the cloud infrastructure as transport and thus prevent having a >20 hops over 4 ISP’s path back to the home router.

For the IPsec part, one thing I noticed is that Apple uses 2 different stacks for their DNS. I take the example of OpenVPN, if your tunnel brings up IPv6 and you are on an IPv4 only network, you will be able to ping in IPv6. But curl won’t work and the browser either. Because for that, you need SCutil to see that IPv6 is available. And it only does so on native interfaces apparently.

The other reason is that, to route back to home, I have a Juniper firewall in front. And that firewall doesn’t support wireguard…

1 Like