#!/bin/sh

ip="$1"
[ -z "$ip" ] && exit

mac="`ip neigh show | grep -v FAILED | grep -v :: | grep "$ip " | awk '{printf toupper($5)}'`"
[ -z "$mac" ] && ping -c 1 -w 1 "$ip" 2>/dev/null >/dev/null
mac="`ip neigh show | grep -v FAILED | grep -v :: | grep "$ip " | awk '{printf toupper($5)}'`"

echo -n "$mac"