Skip to content

Instantly share code, notes, and snippets.

@isdampe
Created January 21, 2017 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isdampe/30149aa28ca60bc4a616003e1050759c to your computer and use it in GitHub Desktop.
Save isdampe/30149aa28ca60bc4a616003e1050759c to your computer and use it in GitHub Desktop.
#!/bin/sh
# pppd ip-up script for all-to-tunnel routing
# name of primary network interface (before tunnel)
PRIMARY=eth0
# address of tunnel server
SERVER=tunnel.example.com
# provided by pppd: string to identify connection aka ipparam option
CONNECTION=$6
if [ "${CONNECTION}" = "" ]; then CONNECTION=${PPP_IPPARAM}; fi
# provided by pppd: interface name
TUNNEL=$1
if [ "${TUNNEL}" = "" ]; then TUNNEL=${PPP_IFACE}; fi
# if we are being called as part of the tunnel startup
if [ "${CONNECTION}" = "tunnel" ] ; then
# direct tunnelled packets to the tunnel server
route add -host ${SERVER} dev ${PRIMARY}
# direct all other packets into the tunnel
route del default ${PRIMARY}
route add default dev ${TUNNEL}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment