WHOIS协议原理_第1页
WHOIS协议原理_第2页
WHOIS协议原理_第3页
WHOIS协议原理_第4页
WHOIS协议原理_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Whois协议原理及使用RFC812定义了一个非常简单的Internet信息查询协议WHOIS协议。其基本内容是,先向服务器的TCP端口43建立一个连接,发送查询关键字并加上回车换行,然后接收服务器的查询结果。世界上各级Internet管理机构秉承公开、公正、共享的原则,设立了可以查知IP地址和域名所有者登记资料的WHOIS服务器,以便所有Internet的使用者排除故障、打击网上非法活动。全世界国际区域性的IP地址管理机构有四个:ARIN、RIPE、APNIC、LACNIC,他们负责的IP地址的地理区域如下图所示。四个国际区域性IP地址管理机构所负责的区域(此图摘自RIPE 2002年度报告)重要的Internet管理机构和常用的WHOIS服务器机构缩写 WHOIS服务器地址 机构全名及地点 提供查询内容CERNIC 中国教育与科研计算机网网络信息中心(清华大学中国北京) 中国教育网内的IP地址和.域名信息CNNIC 中国互联网络信息中心(中国科学院计算机网络信息中心中国北京) .cn域名(除.)信息INTERNIC 互联网络信息中心(美国洛杉矶市Marina del Rey镇) .com,.net,.org,.biz,.info,.name域名的注册信息(只给出注册代理公司)ARIN 美国Internet号码注册中心(美国弗吉尼亚州Chantilly市) 全世界早期网络及现在的美国、加拿大、撒哈拉沙漠以南非洲的IP地址信息APNIC 亚洲与太平洋地区网络信息中心(澳大利亚昆士兰州密尔顿镇) 东亚(包括中国大陆和台湾)、南亚、大洋洲IP地址注信息RIPE 欧州IP地址注册中心(荷兰阿姆斯特丹) 欧洲、北非、西亚地区的IP地址信息TWNIC 台湾互联网络信息中心(中国台湾台北) .tw域名和部分台湾岛内IP地址信息JPNIC whois.nic.ad.jp 日本互联网络信息中心(日本东京) .jp域名和日本境内的IP地址信息KRNIC 韩国互联网络信息中心(韩国汉城) .kr域名和韩国境内的IP地址信息LACNIC 拉丁美洲及加勒比互联网络信息中心(巴西圣保罗) 拉丁美洲及加勒比海诸岛IP地址信息本机上的自动WHOIS服务,是按照下图所示的流程,依次查询若干个WHOIS服务器之后,得到某个IP地址的WHOIS信息。当我们准备建立一个Web站点,就必须向域名登记机构申请一个Internet域名,因此,我们通常希望了解自己准备使用的域名是否已经被注册,这时,可以简单地访问InterNIC站点/whois.html,在Registry Whois输入框中输入需查询的域名,就可以得到我们需要的结果。本文介绍了如何使用Java编程来实现这个过程。一 原理原理非常简单,域名的查询主要是基于RFC 954提供的WHOIS协议。在上述过程中,我们实际上是访问了InterNIC站点的WHOIS服务器,该服务器从WHOIS数据库中查询我们所需要的内容。WHOIS服务器是一个基于查询/响应的TCP事务服务器,它运行在SRI-NIC机器上(3或1),向用户提供internet范围内的目录服务。本地主机上的用户程序可以通过Internet访问该服务器,其过程主要有下面三步:(1)在TCP服务端口43(十进制)连接SRI-NIC服务主机;(2)发送一个命令,以回车和换行()结尾;(3)接受相应命令的返回信息,一旦输出结束,服务器将关闭连接。命令的格式非常简单。可以直接输入域名,例如,可以使用查询搜狐网站的域名信息;也可以使用help得到详细的帮助信息。二 Java socket编程简述在Java中,使用Socket类可以实现客户端的sockets,建立与服务器的网络连接。本文使用下面所示的Socket类的构造器来创建一个流socket,并连接到主机的端口43。public Socket(String host, int port, boolean stream) throws IOException其中,参数host为远程主机的主机名,port为远程主机的端口号,如果参数stream为true,则创建一个流socket,否则创建一个数据报socket。如果创建socket时发生I/O错误,将抛掷一个IOException 异常。当创建了一个连接到远程主机的socket对象后,我们可以使用getInputStream()和getOutputStream()方法分别得到该socket对象的输入流和输出流,用于对该socket进行数据读写,为了使应用程序设计简单,这些方法返回的流通常使用java.io包中的实例对象来处理,例如:DataInputStream和PrintWriter。从socket读数据使用readline()方法,一次读取一行数据(字符串):public String readLine() throws IOException向socket写数据使用print()方法:public void print(String s)当完成socket通讯后,应该首先关闭DataInputStream和PrintWriter对象,最后才关闭socket对象。三 源程序 import .*;import java.io.*;public class whoispublic final static int port = 43;public final static String hostname = ;public static void main(String args)Socket theSocket;DataInputStream theWhoisStream;PrintStream ps;/检查命令行参数if (args.length 1)System.out.println(nUsage: java whois );System.out.println(Parameters:);System.out.println(tcommand = one or more Domain name, or other command.);System.out.println(Example:);System.out.println(tjava whois );System.out.println(tjava whois help);System.exit(1); /退出try /在TCP服务端口43(十进制)连接SRI-NIC服务主机theSocket = new Socket(hostname, port, true);ps = new PrintStream(theSocket.getOutputStream();/发送用户提供的一个或多个命令for (int i = 0; i Last update of whois database: Tue, 03 Mar 2009 03:37:55 UTC NOTICE: The expiration date displayed in this record is the date theregistrars sponsorship of the domain name registration in the registry iscurrently set to expire. This date does not necessarily reflect the expirationdate of the domain name registrants agreement with the sponsoringregistrar. Users may consult the sponsoring registrars Whois database toview the registrars reported date of expiration for this registration.TERMS OF USE: You are not authorized to access or query our Whoisdatabase through the use of electronic processes that are high-volume andautomated except as reasonably necessary to register domain names ormodify existing registrations; the Data in VeriSign Global RegistryServices (VeriSign) Whois database is provided by VeriSign forinformation purposes only, and to assist persons in obtaining informationabout or related to a domain name registration record. VeriSign does notguarantee its accuracy. By submitting a Whois query, you agree to abideby the following terms of use: You agree that you may use this Data onlyfor lawful purposes and that under no circumstances will you use this Datato: (1) allow, enable, or otherwise support the transmission of massunsolicited, commercial advertising or solicitations via e-mail, telephone,or facsimile; or (2) enable high volume, automated, electronic processesthat apply to VeriSign (or its computer systems). The compilation,repackaging, dissemination or other use of this Data is expresslyprohibited without the prior written consent of VeriSign. You agree not touse electronic processes that are automated and high-volume to access orquery the Whois database except as reasonably necessary to registerdomain names or modify existing registrations. VeriSign reserves the rightto restrict your access to the Whois database in its sole discretion to ensureoperational stability. VeriSi

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论