如何解决如何通过发送和接收数据包手动获取网站的IP地址,从而抛出Google DNS,OpenDNS…
| 我想编写一个小程序,通过手动发送和接收来自Google DNS,Open DNS的数据包来获取某些网站的IP地址。 怎么可以帮我 我写了这个,但是不能正常工作。public static void main(String args[]) throws Exception
{
String str=\"stackoverflow.com\";
DatagramPacket dp=new DatagramPacket(str.getBytes(),str.length());
DatagramSocket ds=new DatagramSocket();
dp.setAddress(InetAddress.getByName(\"8.8.8.8\"));
dp.setPort(53);
ds.send(dp);
System.out.println(\"SENDED\");
byte[] receive=new byte[1024];
dp.setData(receive);
System.out.println(\"PREPARING FOR RECEIVE : \");
ds.receive(dp);
System.out.println(new String(receive));
}
解决方法
您将需要实施DNS协议-起点可以是http://tools.ietf.org/html/rfc1035
, 如果您不想实施DNS协议,dnsjava可能会让您感兴趣。
, DNS协议在RFC 1034中定义。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。