VPNC connect & test script (used to connect to fritzbox vpn)
#!/bin/bash
#
##
# Find current default gateway via: ip route | grep default
#
# Note: VPN interface will be prefixed with 'tun'!
#
# Config template for /etc/vpnc/fritzbox.conf:
##
# IPSec gateway <DynIP / Hostname>
# IPSec ID <Username>
# IPSec secret <Shared Password>
# IKE Authmode psk
# Xauth username <Username>
# Xauth password <Password>
# local port 0
# DPD idle timeout (our side) 0
##
# Settings:
##
_def_gateway=<default local gateway>
_vpn_gateway=<gateway in vpn eg.: 192.168.178.1>
_vpn_net=<vpn network e.g.: 192.168.178.0>
_vpn_netmask=<netmask of VPN net eg.: 255.255.255.0>
_vpn_iface=_fboxvpn
##
if ping -W 1 -c 1 $_vpn_gateway &> /dev/null
then
echo "Already connected."
else
vpnc-disconnect
sleep 2
echo "Connecting..."
vpnc --ifname tun$_vpn_iface fritzbox.conf && route add default gw $_def_gateway && route add -net $_vpn_net netmask $_vpn_netmask dev tun$_vpn_iface
fi