e91e8ae2fe
+ Tweak Makefile + Add vpnc-disconnect ok okan@ ajacoutot@
32 lines
626 B
Bash
32 lines
626 B
Bash
#! /bin/sh
|
|
|
|
# $OpenBSD: vpnc.sh,v 1.4 2009/01/29 19:07:06 pea Exp $
|
|
|
|
TUN_IF=tun0
|
|
PHYS_IF=wi0
|
|
VPNGATEWAY=192.168.0.1
|
|
|
|
case "$1" in
|
|
start)
|
|
dhclient ${PHYS_IF}
|
|
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
|
|
pkill "dhclient ${PHYS_IF}"
|
|
ifconfig ${PHYS_IF} down
|
|
;;
|
|
*)
|
|
echo "Usage: `basename $0` {start|stop}" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
exit 0
|