final ResolverConfig currentConfig = ResolverConfig.getCurrentConfig();
if (currentConfig != null) {
final Name[] searchPath = currentConfig.searchPath();
if (searchPath != null) {
for (Name domain : searchPath) {
if (hostname.subdomain(domain)) {
return hostname.relativize(domain).toString();
}
}
}
}