#!/bin/sh
#
# FreeBSD 6.2 Release
#
TUNIF=gre0
meLAN=192.168.0.254
remLAN=192.168.1.254
remNET=192.168.1
remMSK=255.255.255.0
meWAN=X.X.X.X
remWAN=Y.Y.Y.Y
case $1 in
start|faststart)
echo "Creating GRE tunnel..."
ifconfig $TUNIF create mtu 1392 || (echo "GRE tunnel not functional or interface $TUNIF already exists. Cannot create interface $TUNIF. Check `basename $0`."; exit 1);
ifconfig $TUNIF $meLAN $remLAN link1
ifconfig $TUNIF tunnel $meWAN $remWAN
route add -net $remNET -netmask $remMSK $remLAN
ifconfig $TUNIF
;;
stop)
echo "Destroying GRE tunnel..."
route delete -net $remNET -netmask $remMSK $remLAN
ifconfig $TUNIF down
ifconfig $TUNIF destroy
echo "Done."
;;
*) echo "Usage: ./`basename $0` (start|stop)" ;;
esac
#!/bin/bash
#
# CentOS release 4.2 (Final)
#
TUNIF=gre0
remWAN=X.X.X.X
meWAN=Y.Y.Y.Y
meLAN=192.168.1.254
remGW=192.168.0.254
remLAN=192.168.0.0/24
/sbin/modprobe ip_gre || exit 2
/bin/echo Creating GRE tunnel...
/sbin/ip tunnel add $TUNIF mode gre local $meWAN remote $remWAN ttl 255 || (/bin/echo "GRE tunnel not functional. Cannot create interface $TUNIF. Check `basename $0`."; exit 3);
/sbin/ip addr add $meLAN dev $TUNIF
/sbin/ip link set $TUNIF mtu 1392 up
/sbin/ip route add $remLAN dev $TUNIF
/sbin/ifconfig $TUNIF || (echo "GRE tunnel not functional. Check `basename $0`."; exit 4);