2004-05-14 09:34:51 -04:00
|
|
|
#! /bin/sh
|
|
|
|
|
2005-05-05 06:54:48 -04:00
|
|
|
# $OpenBSD: vpnc.sh,v 1.3 2005/05/05 10:54:48 sturm Exp $
|
2004-06-29 15:45:46 -04:00
|
|
|
|
2004-05-14 09:34:51 -04:00
|
|
|
TUN_IF=tun0
|
2005-05-05 06:54:48 -04:00
|
|
|
PHYS_IF=wi0
|
2004-05-14 09:34:51 -04:00
|
|
|
PREFIX=%%PREFIX%%
|
|
|
|
VPNGATEWAY=192.168.0.1
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
2005-05-05 06:54:48 -04:00
|
|
|
dhclient ${PHYS_IF}
|
2004-05-14 09:34:51 -04:00
|
|
|
DEFAULTROUTER=`route -n show -inet | grep default | awk '{ print $2 }'`
|
|
|
|
${PREFIX}/sbin/vpnc || exit 1
|
|
|
|
TUN_IP=`ifconfig ${TUN_IF} | grep netmask | awk '{ print $2 }'`
|
|
|
|
route add -host ${VPNGATEWAY} ${DEFAULTROUTER}
|
|
|
|
route delete default
|
|
|
|
route add default -interface ${TUN_IP}
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
route delete -host ${VPNGATEWAY}
|
|
|
|
pkill vpnc
|
2005-05-05 06:54:48 -04:00
|
|
|
pkill "dhclient ${PHYS_IF}"
|
|
|
|
ifconfig ${PHYS_IF} down
|
2004-05-14 09:34:51 -04:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: `basename $0` {start|stop}" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|