function get_client_mac_address() { # Usage: get_client_mac_address local ETH_IFACE="$1" local TARGET_IP="192.168.2.2" # Check if the interface is plugged in if ip link show "$ETH_IFACE" | grep -q "state UP"; then local MAC_ADDRESS=$(arp -i "$ETH_IFACE" -n | grep "$TARGET_IP" | awk '{print $3}') if [ -n "$MAC_ADDRESS" ]; then echo "$MAC_ADDRESS" else exit 1 fi else exit 1 fi }