Skip to content

Instantly share code, notes, and snippets.

@bsmithyman
Created October 5, 2014 04:20
Show Gist options
  • Save bsmithyman/174a7d062e47af171cb3 to your computer and use it in GitHub Desktop.
Save bsmithyman/174a7d062e47af171cb3 to your computer and use it in GitHub Desktop.
OpenVPN up script to add route to custom table
#!/bin/bash
TUNNEL="tun0"
TABLE="tablename"
OUTADDR=$(ip addr | grep $TUNNEL | sed -nr 's/.*peer ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*/\1/p')
ip route add default via $OUTADDR dev $TUNNEL table $TABLE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment