Skip to content

Instantly share code, notes, and snippets.

@information-security
Created October 16, 2020 03:35
Show Gist options
  • Save information-security/cad35bf45e6a504ffcf0467fdda0d846 to your computer and use it in GitHub Desktop.
Save information-security/cad35bf45e6a504ffcf0467fdda0d846 to your computer and use it in GitHub Desktop.
How to automatically add routes after VPN connections in MAC OSX
Create the file /etc/ppp/ip-up with following content:
#!/bin/sh
/sbin/route add <SUBNET> -interface $1
replacing <SUBNET> with subnet, you want to route through VPN (for ex. 192.168.0.0/16)
execute as root:
chmod 0755 /etc/ppp/ip-up
This file will be executed each time you connect to VPN.
The parameters given to the script:
$1: The VPN interface (e.g. ppp0)
$2: Unknown, was 0 in my case
$3: IP of the VPN server
$4: VPN gateway address
$5: Regular (non-vpn) gateway for your lan connections
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment