Skip to content

Instantly share code, notes, and snippets.

@ryancdotorg
Created March 14, 2020 17:05
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 ryancdotorg/eb151c59c51d66d07213c6f87a1f3c8d to your computer and use it in GitHub Desktop.
Save ryancdotorg/eb151c59c51d66d07213c6f87a1f3c8d to your computer and use it in GitHub Desktop.
Sets up routing when you don't have an on-subnet IP configured.
#!/bin/sh
IFACE="$1"
SRCIP="$2"
DSTIP="$3"
MAC=`/usr/sbin/arping -r -C1 -w10 -i "$IFACE" -S "$SRCIP" "$DSTIP"`
if [ $? -eq 0 ]
then
/sbin/ip neigh replace "$DSTIP" lladdr "$MAC" dev "$IFACE" nud permanent || exit $?
/sbin/ip route replace default via "$DSTIP" dev "$IFACE" || exit $?
else
exit $?
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment