Created
January 21, 2017 06:11
-
-
Save isdampe/30149aa28ca60bc4a616003e1050759c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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