Skip to content

Instantly share code, notes, and snippets.

@melnik13 melnik13/
Last active Aug 29, 2015

What would you like to do?
Need to check some host's availability by arping, but have no time to look up which network intrface you need? is here to help you.
if [ -z "${1}" ]; then
echo "Chocho?" >&2
exit 1
HOSTIP="${@: -1}"
ROUTE=$(ip route get "${HOSTIP}")
if [ -z "${ROUTE}" ]; then
echo "Can't find the route to this host" >&2
exit 1
IFACE=$(echo "${ROUTE}" | sed -rn "s/^.*dev (eth.[0-9\.]+)[[:space:]]+.*$/\1/gp")
if [ -z "${IFACE}" ]; then
echo "Can't find the interface of this host" >&2
exit 1
exec arping -I "${IFACE}" ${@}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.