Skip to content

Instantly share code, notes, and snippets.

@syed
Created December 28, 2017 04:19
Show Gist options
  • Save syed/716ef4019a5aa29cfe3117aae00e3442 to your computer and use it in GitHub Desktop.
Save syed/716ef4019a5aa29cfe3117aae00e3442 to your computer and use it in GitHub Desktop.
#!/bin/bash
LOCAL_IP=$(hostname -i)
REMOTE_IP=$1
LOCAL_TUNNEL_IP=$2
REMOTE_TUNNEL_IP=$3
display_usage() {
echo -e "\nUsage: $0 [remote ip address] [local tunnel ip] [remote tunnel ip] \n"
}
if [ $# -lt 3 ]
then
display_usage
exit 1
fi
if [[ $USER != "root" ]]; then
echo "This script must be run as root!"
exit 1
fi
modprobe ipip
ip tunnel add tunl1 mode ipip remote $REMOTE_IP local $LOCAL_IP ttl 255
ifconfig tunl1 $LOCAL_TUNNEL_IP
route add -host $REMOTE_TUNNEL_IP dev tunl1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment