Skip to content

Instantly share code, notes, and snippets.

Last active March 16, 2023 13:33
What would you like to do?

Attempt to manage vpn routing table with /etc/ppp/ip-up

Related Stackoverflow Question:

Related answer:

# setup
sudo touch /etc/ppp/ip-up
sudo vim /etc/ppp/ip-up # fill the script
sudo chmod +x /etc/ppp/ip-up
# tail the logs
sudo tail -f /var/log/ip-up.log

Tested on MacOS 10.13 and didn't work for me. Script doesn't get called.
This works, shebang was wrong. Thanks to athairus and Mark Gaensicke in the comments. 🙌



  • 2022-11-02: I've updated the script to reflect suggested changes in comments and I've added logging of the command
now=`date +%Y-%m-%d_%Hh%Mm%Ss`
echo "$0 called at $now with following params:" >> $logfile
echo "The VPN interface (e.g. ppp0): $1" >> $logfile
echo "Unknown, was 0, in my case: $2" >> $logfile
echo "IP of the VPN server: $3" >> $logfile
echo "VPN gateway address: $4" >> $logfile
echo "Regular (non-vpn) gateway for your lan connections: $5" >> $logfile
# Add to range to routing table on VPN interface
/sbin/route add -net -interface $1 >> $logfile 2>&1
Copy link

You forgot the bang in the shebang:


See my fork.

Copy link

algal commented Sep 8, 2018

With this fix, it works for me on macOS 10.13.16, I needed to update the command to this for my purposes:

/sbin/route add -host -interface $1

Copy link

First line should be:


instead of #/bin/sh. Without correct Shebang the script will not be executed.

Copy link

cptfixit commented Nov 2, 2022

The script still isn't right :)

You wrote:
#/sbin/route add -interface $1

The actual call to route should be:
/sbin/route add -net -interface $1

Note that:

  • Your original made it a comment (by starting with #)
  • Without -net it becomes a route for a single address, not for a network.

Copy link

Thanks I've updated the gist accordingly 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment