- if ($remoteip eq ""){next;}
- if (system("ipsec whack --status | grep $remoteip >/dev/null")){
- logger("Remote IP for host $remotehostname has changed or is not connected, restarting connection to $remoteip.");
- system("/usr/local/bin/ipsecctrl S $settings[0]");
- next;
+ if ($remoteip eq ""){next;if ($debug){logger("Unable to resolve $remotehostname.");}}
+ my $ipmatch= `echo "$status" | grep $remoteip | grep $settings[2]`;
+
+ if ( $ipmatch eq '' ){
+ logger("Remote IP for host $remotehostname-$remoteip has changed, restarting ipsec.");
+ system("/usr/local/bin/ipsecctrl S");
+ last; #all connections will reloaded