Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Mark Knowles' Blog has a good explanation on how to maintain a persistent vpnc connection. However, this doesn't work well for multiple vpnc connections (Connecting doesn't work for me, everything gets reconnected on a single disconnect, ...). Is there a better way of maintaining multiple vpnc connections?

share|improve this question

The following modifications work well for multiple profiles:

  1. Add Local Port 0 to your .conf files in /etc/vpnc, if you haven't done so. This will use random local ports, and will allow multiple connections better.
  2. For every connection, pick an IP and port on the vpn network which you want to connect to (and maintain a connection to). For every connection, write a script in /usr/local/bin that checks the connection is still possible and if not launches vpnc, e.g. with

    if ! nc -z -w 2 targetip targetport
    then /usr/sbin/vpnc-connect connectionprofile.conf
  3. Change the reconnect script /etc/vpnc/reconnect-script to use all of those scripts (do them one after another, so no & at the end)

    sleep 30
  4. The /etc/init.d/vpnc script is almost the same, except you don't need to source /etc/default/vpnc any longer

Don't forget that scripts need to be executable. As long as you call them from root, these scripts work very well in any automated cron-jobs, e.g. before you call scp or rdesktop on any box in the vpn network, just do a quite You can always drop back out of root with a su -u yourusername command. And use root's crontab, obviously.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .