#!/bin/bash # Script by Juan Nicolas Ruiz # Used with his kind permission. # Setting up (and stopping) a GRE tunnel. # --- start-tunnel.sh --- LOCAL_IP="192.168.1.17" REMOTE_IP="10.0.5.33" OTHER_IFACE="192.168.0.100" REMOTE_NET="192.168.3.0/24" /sbin/ip tunnel add netb mode gre remote $REMOTE_IP \ local $LOCAL_IP ttl 255 /sbin/ip addr add $OTHER_IFACE dev netb /sbin/ip link set netb up /sbin/ip route add $REMOTE_NET dev netb exit 0 ############################################# # --- stop-tunnel.sh --- REMOTE_NET="192.168.3.0/24" /sbin/ip route del $REMOTE_NET dev netb /sbin/ip link set netb down /sbin/ip tunnel del netb exit 0