import org.xbill.DNS._
val resolver = new SimpleResolver("8.8.8.8")
val lookup = new Lookup("example.com")
lookup.setResolver(resolver)
val records = lookup.run()
val address = records.asInstanceOf[ARecord].getAddress()
import org.xbill.DNS.*;
public Class ChoseDNSServer
{
private SimpleResolver sp;
private Lookup look;
public ChoseDNSServer(String ip)
{
//Provide ip of server you want to choose for your DNS query
sp = new SimpleResolver(ip);
look = new Lookup("URL");
look.setResolver(sp);
//Above method is used for setting up default DNS server.
}
public switchToServer(String ip)
{
sp = new SimpleResolver(ip);
look.setResolver(sp);
}
public Record lookup(String url)
{
look = new Lookup(url);
return look.run();
}
}
2条答案
按热度按时间wd2eg0qa1#
这在dnsjava的例子中是没有的,但是我发现了这一点:
(in斯卡拉)
uelo1irk2#