We help IT Professionals succeed at work.
Get Started

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

hypervisor asked
Last Modified: 2013-05-29
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

Open in new window

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: 

Open in new window

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

Watch Question
Software Developer
This problem has been solved!
Unlock 1 Answer and 25 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE