Skip to content

Instantly share code, notes, and snippets.

@Informatic
Created December 12, 2018 18:44
#!/bin/bash
#
# Replace all metrics for all routes on this openvpn connection.
#
# Usage:
#
# script-security 2
# up "/etc/openvpn/change-metric.sh 3000"
# route-up "/etc/openvpn/change-metric.sh 3000" # Alternatively
#
set -ex
metric="$1"; shift
[[ -z "$dev" ]] && dev="$1" && shift
ip route show dev $dev | while read route; do
ip route del $route dev $dev
ip route add $route dev $dev metric $metric
echo "route [[ $route ]] $metric | $dev"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment