#!/bin/sh
# This is a GRE example script. Use at your own risk!
#
# You'll need two of these (one for each end of the tunnel). You should
# really only have to swap ThisEnd and OtherEnd, set a different InternalIP,
# and pick which networks you want to route for each side. No other changes
# should be needed.
#
# If you're doing GRE tunneling with NoCatAuth, also be sure to clear the
# traffic through your gateway, or packets will just drop on the floor!
#
# The advanced router tools package (specifically ip) is required for this
# script. Get it online here: ftp://ftp.inr.ac.ru/ip-routing/
#
# Assembled 7/30/02, by Rob Flickenger <rob@nocat.net>.
# This is Freeware. Do something free with it.
#
# Set ThisEnd to the live, routed, "real" IP address on this end of the tunnel
#
ThisEnd="240.101.83.2"
#
# OtherEnd is the live, routed, "real" IP address of the other end
#
OtherEnd="251.4.92.217"
#
# Set InternalIP to any unused IP address on the same subnet as your
# internal interface
#
InternalIP="10.42.3.62"
#
# Give this tunnel a short, alphanumeric name
#
TunnelName="tunnel0"
#
# List all networks that you'd like to route down the tunnel here.
#
RemoteNets="10.42.2.0/26 10.42.5.0/26"
#
# That's it. No user serviceable parts below!
PATH=/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin
#
modprobe ip_gre
#
ip tunnel add $TunnelName mode gre remote $OtherEnd local $ThisEnd ttl 255
ip addr add $InternalIP dev $TunnelName
ip link set $TunnelName up
#
for net in $RemoteNets; do
ip route add $net dev $TunnelName
done
echo "$TunnelName is up. To bring it down again, try this:"
echo ""
echo "ip link set $TunnelName down"
echo "ip tunnel del $TunnelName"
echo ""
echo "Have fun..."
#
# Ende