So digging into this a bit more I used:
sudo fs_usage | grep /var/run/racoon
and opened a VPN to find out what creates the racoon .conf files for the VPN with the default 3600 seconds timeout.
This showed it was the configd daemon
14:44:31 lstat64 private/var/run/racoon/W.X.Y.Z.conf 0.000015 configd
14:44:31 stat64 private/var/run/racoon 0.000008 configd
14:44:31 open private/var/run/racoon/W.X.Y.Z.conf 0.000084 configd
14:44:31 open private/var/run/racoon.pid 0.000006 configd
Digging around in the apple source code it appears the line of code that sets the proposal Lifetime might be configurable through configuration:
http://www.opensource.apple.com/source/ppp/ppp-233.0.2/Helpers/vpnd/ipsec_utils. c
proposals = CFDictionaryGetValue(ipsec_dict, kRASPropIPSecProposals);
if (isArray(proposals))
nb = CFArrayGetCount(proposals);
do {
if (nb) {
proposal = CFArrayGetValueAtIndex(proposals, i);
if (!isDictionary(proposal))
FAIL("incorrect phase 1 proposal");
}
WRITE("\n");
WRITE("proposal {\n");
if (configure_proposal(level + 1, file, ipsec_dict, proposal, errstr))
goto fail;
WRITE("}\n");
} while (++i < nb);
-------------------------------------------- snip snip -------------------------------------
static int configure_proposal(int level, FILE *file, CFDictionaryRef ipsec_dict, CFDictionaryRef proposal_dict, char **errstr);
-------------------------------------------- snip snip -------------------------------------
/*
Lifetime is OPTIONAL
*/
{
u_int32_t lval = 3600;
if (proposal_dict) {
GetIntFromDict(proposal_dict, kRASPropIPSecProposalLifetime, &lval, 3600);
}
sprintf(text, "lifetime time %d sec;\n", lval);
WRITE(text);
}
But I couldn't figure out where this function is defined to trace where the configuration file might be:
CFDictionaryGetValue(ipsec_dict, kRASPropIPSecProposals);
Any ideas anyone?
The 45min to 1 hour VPN cut off is a major PITA!
And in case Apple think they're gods, vpnc under Linux works fine .
Cheers,
racitup
Fotos Georgiadis wrote:
I have the same problem with the VPN dropping after ~45 minutes.
matthew4130 is correct. There is an IKE rekey attempt every 45 or so minutes. The default ipsec SA lifetime is an hour (3600 seconds). The lifetime is configured, on Cisco routers, using the command:
crypto ipsec security-association lifetime
Also the default isakmp policy lifetime is a day (86400 seconds) but a lot of administrators lower this for security reasons:
crypto isakmp policy
AFAIK the problem isn't related to aggressive mode or main mode being selected, which both are explained here:
https://supportforums.cisco.com/docs/DOC-8125
Most likely what matthew4130 sees is that when main mode is enabled a different crypto group, with a bigger lifetime, is selected for the security association (lucky you!). IMHO you shouldn't change the lifetime since 1 hour is reasonable to prevent key recovery attacks.
You can also see the SA lifetime of YOUR ipsec connection using this terminal command on your Mac:
$ sudo racoonctl ss ipsec
You should see something like this:
diff: 140(s) |
hard: 3600(s) |
soft: 2880(s) |
Digging deeper into this I decided to check the (open) source code for ppp available by Apple here:
http://www.opensource.apple.com/source/ppp/ppp-560.14.2/
As you can see in ipsec_manager.c function process_racoon_msg() the connection is dropped with the message you are seeing (IPSec Controller: XAuth reauthentication dialog required, so connection aborted) when a REAUTHINFO message is received and the flag XAUTH_MUST_PROMPT is set in the xauth_flags.
Note that this code is enabled only when the OS is not for embedded devices (i.e. iPad, iPhone, etc). The message is discarded on those devices and that's why you won't see the 1 hour limit on the iPad or the iPhone.
Now the fix seems easy; instead of dropping the connection when xauth is requested at least prompt the user for the password again using process_xauth_need_info().
Also if you look at an older version of ipsec_manager.c(412.5) that was the previous behavior; reauthenticating instead of dropping the connection. No idea why Apple changed (actually broke 🙂) this!
BTW when sending the phase2 command to racoon with racoon_send_cmd_start_ph2() there seems to be a hardcoded default lifetime of 3600 seconds...
All we have to do now is get an Apple engineer to see this post and fix the code!
-fotos
PS1. The IPSec source code is a mess. 😟
PS2. I logged in with my Apple ID to post this and now my username is stuck as my full name. Privacy fail? 😟