Skip to content

Instantly share code, notes, and snippets.

@rightson
Created August 14, 2018 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rightson/fdac61958d82a88f6ec74cc4ffcecb3f to your computer and use it in GitHub Desktop.
Save rightson/fdac61958d82a88f6ec74cc4ffcecb3f to your computer and use it in GitHub Desktop.
A utility that can quickly set default gateway's metric to 0 or delete entire routing rule
#!/bin/bash
op=$1
iface=$2
gateway=$3
if [ -z "$op" ]; then
op=add
fi
if [ -z "$iface" ]; then
iface=eth1
fi
if [ -z "$gateway" ]; then
gateway=172.20.10.1
fi
cmd="sudo route $op -net default gw $gateway netmask 0.0.0.0 dev $iface metric 0"
echo $cmd
$cmd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment