troubleshooting Question

Need a script to re-initiate a OpenSwan VPN tunnel when it fails

Avatar of hypervisor
hypervisor asked on
Shell Scripting
25 Comments1 Solution665 ViewsLast Modified:
I need to initiate the following commands if a ping fails to an IP address.

sudo ipsec whack --name sonicwall --delete
sudo ipsec auto --add sonicwall
sudo ipsec whack --name sonicwall --initiate

The last command prompts for a username and password (as displayed below.)  The script will need to provide the username and password.
[ec2-user@ip-10-170-95-135 ~]$ sudo ipsec whack --name sonicwall --initiate
002 "sonicwall" #41: initiating Aggressive Mode #41, connection "sonicwall"
112 "sonicwall" #41: STATE_AGGR_I1: initiate
003 "sonicwall" #41: ignoring Vendor ID payload [Sonicwall 1 (TZ 170 Standard?)]
003 "sonicwall" #41: ignoring unknown Vendor ID payload [5b362bc820f60007]
003 "sonicwall" #41: received Vendor ID payload [Dead Peer Detection]
003 "sonicwall" #41: received Vendor ID payload [XAUTH]
002 "sonicwall" #41: Aggressive mode peer ID is ID_FQDN: '@0017C5120524'
002 "sonicwall" #41: transition from state STATE_AGGR_I1 to state STATE_AGGR_I2
004 "sonicwall" #41: STATE_AGGR_I2: sent AI2, ISAKMP SA established {auth=OAKLEY_PRESHARED_KEY cipher=oakley_3des_cbc_192 prf=oakley_sha group=modp1024}
041 "sonicwall" #41: sonicwall prompt for Username:
Enter username:   amazoncloudCA
040 "sonicwall" #41: sonicwall prompt for Password:
Enter passphrase: 

I don't particularly care what scripting tools are used to get this done.

Duncan Roe
Software Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 25 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 25 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros