Skip to content

Instantly share code, notes, and snippets.

@copiousfreetime
Created September 1, 2011 20:24
Show Gist options
  • Save copiousfreetime/1187174 to your computer and use it in GitHub Desktop.
Save copiousfreetime/1187174 to your computer and use it in GitHub Desktop.
PPP ip-up/ip-down for vpn with optional dns resolving
#!/bin/sh
# install into /etc/ppp/ip-down
# chmod a+x /etc/ppp/ip-down
source /etc/ppp/ip.config
case "${IPREMOTE}" in
${MY_IPREMOTE})
/sbin/route delete ${MY_ROUTE} -interface ${IFNAME}
mv ${RESOLV_CONF}.ip-up ${RESOLV_CONF}
;;
esac
exit 0
#!/bin/sh
# install into /etc/ppp/ip-up
# chmod a+x /etc/ppp/ip-up
source /etc/ppp/ip.config
if [ "${DUMP_ENV}" = "yes" ]; then
env > /tmp/ip-up.env
fi
case "${IPREMOTE}" in
${MY_IPREMOTE})
/sbin/route add ${MY_ROUTE} -interface ${IFNAME}
cp ${RESOLV_CONF} ${RESOLV_CONF}.ip-up
echo "nameserver ${MY_NAMESERVER}" >> ${RESOLV_CONF}
;;
esac
exit 0
#!/bin/sh
# Dump the current environment to a log file for debugging
DUMP_ENV=yes
# The ip address of the vpn gateway, probaby connect to the vpn
MY_IPREMOTE="a.b.c.d"
# The nameserver to you want to use if your VPN server doesn't send it
# You might also look at the $DNS1, $DNS2 vars spit out from the env dump
MY_NAMESERVER="a.b.c.d"
# The route to add to send through the ppp interface
MY_ROUTE="a.b.c/16"
# The resolv.conf file to update. By default on mac osx /etc/resolv.conf is a
# symlink to /var/run/resolv.conf
RESOLV_CONF=/var/run/resolv.conf
j
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment