• RSS
  • Facebook
  • Twitter
  • Linkedin
  • Google +
  • Youtube

Tras realizar una tarea de migración de zonas de un servidor de DNS Windows a Bind de Linux, nos hemos visto con la necesidad de hacer ciertas consultas whois sobre las zonas para saber a qué name servers(NS) están apuntando.

Básicamente, hemos tenido que desarrollar una serie de clases que nos automatizaran el proceso de consultas a los servidores whois para cada una de las extensiones de los dominios.

Al final de todo el proceso, hemos podido empaquetar y adjuntar las clases a nuestra querida librería DomiLibrary.Utility. Las hemos subido ya a nuestro repositorio público en GitHub para que os las podáis descargar para usarla o simplemente ver cómo lo hemos desarrollado.

Si las veis interesantes para algún proyecto, os las podéis descargar con NuGet para su uso con Visual Studio ejecutando la siguiente linea de código: PM> Install-Package DomiLibrary.Utility

Dicho esto, vamos a explicar cómo están montadas las clases y cómo las podéis usar:

  • WhoisServerEnum: clase que contiene constantes con la relación de extensión de dominio y servidor whois que tiene asociado para hacer la consulta.
  • WhoisServerProxy: nos devuelve, pasado una extensión de dominio, el servidor whois que tiene relacionado.
  • WhoisServerHelper: es la clase que contiene toda la lógica necesaria para ejecutar los whois y obtener las propiedades que devuelve el comando.

Vamos a ver un ejemplo de cómo usar las librerías de whois:

var url = "domitienda.com";
var whoisServer = WhoisServerProxy.Proxy("com");
var result = WhoisServerHelper.GetWhoisInformationComplete(whoisServer, url);

Este sería un pequeño fragmento del algoritmo que lanza el whois:

public static string GetWhoisInformation(string whoisServer, string url)
{
	ValidationHelper.NotBlank(whoisServer);
	ValidationHelper.NotBlank(url);

	var stringBuilderResult = new StringBuilder();
	var tcpClinetWhois = new TcpClient(whoisServer, 43);
	var networkStreamWhois = tcpClinetWhois.GetStream();
	var bufferedStreamWhois = new BufferedStream(networkStreamWhois);
	var streamWriter = new StreamWriter(bufferedStreamWhois);

	streamWriter.WriteLine(url);
	streamWriter.Flush();

	var streamReaderReceive = new StreamReader(bufferedStreamWhois);

	try
	{
		while (!streamReaderReceive.EndOfStream)
			stringBuilderResult.AppendLine(streamReaderReceive.ReadLine());

		return stringBuilderResult.ToString();
	}
	catch (Exception)
	{
		return string.Empty;
	}
}

Tras ejecutar estas lineas de código el resultado que obtendríamos sería el siguiente:

Whois Server Version 2.0

Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.

   Domain Name: DOMITIENDA.COM
   Registrar: ENOM, INC.
   Whois Server: whois.enom.com
   Referral URL: http://www.enom.com
   Name Server: DNS1.BUSINET-ISP.COM
   Name Server: DNS2.BUSINET-ISP.COM
   Status: clientTransferProhibited
   Updated Date: 30-nov-2010
   Creation Date: 17-apr-2005
   Expiration Date: 17-apr-2013

>>> Last update of whois database: Thu, 17 Jan 2013 10:58:25 UTC <<<

NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar.  Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.

TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' ("VeriSign") Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability.  VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.

The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars.
=-=-=-=
Visit AboutUs.org for more information about domitienda.com
<a href="http://www.aboutus.org/domitienda.com">AboutUs: domitienda.com</a>

Domain name: domitienda.com

Registrant Contact:
   Hosting Valencia SLU
   Adolfo Molto Herruzo ()

   Fax:
   jose perez fuster, 20 5b
   Valencia, VALENCIA 46007
   ES

Administrative Contact:
   Hosting Valencia SLU
   Adolfo Molto Herruzo (dominios@domitienda.com)
   +34.34963536737
   Fax: +34.34963534639
   jose perez fuster, 20 5b
   Valencia, VALENCIA 46007
   ES

Technical Contact:
   Hosting Valencia SLU
   Adolfo Molto Herruzo (dominios@domitienda.com)
   +34.34963536737
   Fax: +34.34963534639
   jose perez fuster, 20 5b
   Valencia, VALENCIA 46007
   ES

Status: Locked

Name Servers:
   dns1.businet-isp.com
   dns2.businet-isp.com

Creation date: 17 Apr 2005 10:26:08
Expiration date: 17 Apr 2013 10:26:08

Get Noticed on the Internet!  Increase visibility for this domain name by listing it at www.whoisbusinesslistings.com
=-=-=-=
The data in this whois database is provided to you for information
purposes only, that is, to assist you in obtaining information about or
related to a domain name registration record. We make this information
available "as is," and do not guarantee its accuracy. By submitting a
whois query, you agree that you will use this data only for lawful
purposes and that, under no circumstances will you use this data to: (1)
enable high volume, automated, electronic processes that stress or load
this whois database system providing you this information; or (2) allow,
enable, or otherwise support the transmission of mass unsolicited,
commercial advertising or solicitations via direct mail, electronic
mail, or by telephone. The compilation, repackaging, dissemination or
other use of this data is expressly prohibited without prior written
consent from us.

We reserve the right to modify these terms at any time. By submitting
this query, you agree to abide by these terms.
Version 6.3 4/3/2002

La librería soporta las siguiente extensiones de dominio:

  • com
  • net
  • org
  • info
  • ws
  • me
  • eu
  • biz
  • us

Esperamos que os haya sido de ayuda la entrada y sobretodo la librería que hemos implementado. También podéis utilizar la herramienta de whois desde nuestra aplicación web que hemos puesto a vuestro servicio.

The following two tabs change content below.
Empresa de Hosting & IT Consulting

Latest posts by Domitienda (see all)

Categorías: .NET

Deja un comentario