#!/usr/bin/env bash # # - create GRE tunnel between two servers # ####### FREEBSD ####### PATH="/bin:/usr/sbin:/usr/bin:/sbin:/usr/local/bin:/usr/local/sbin" TUNNEL_IF=gre10 # exit node LOCAL_ADDR_EXT=88.32.99.91 LOCAL_ADDR_INT=10.254.20.1 # entry node REMOTE_ADDR_EXT=162.210.201.13 REMOTE_ADDR_INT=10.254.10.1 ####################### # create interface ifconfig "$TUNNEL_IF" create # setup internal address on interface ifconfig "$TUNNEL_IF" "$LOCAL_ADDR_INT" "$REMOTE_ADDR_INT" link1 # up tunnel ifconfig "$TUNNEL_IF" tunnel "$LOCAL_ADDR_EXT" "$REMOTE_ADDR_EXT" # add route to entry node route add -net "${REMOTE_ADDR_INT%.*}" -netmask 255.255.255.0 "$LOCAL_ADDR_INT"