Feature/fix nameserver restoring

cherry-picked from debian branch