‘ Networking ’ category archive

Whois command in UNIX

June 02, 08 by the programmer

If you want to find out some informations about a domain name and you are running unix than you should use the whois command.

Usage: whois [OPTIONS] [QUERY]

Bellow is the list of the options

–version display version number and patch level
–help display this help
-v, –verbose verbose debug output
-c FILE, –config=FILE use FILE as configuration file
-h HOST, –host=HOST explicitly query HOST
n, –no-redirect - disable content redirection
-s, –no-whoisservers disable whois-servers.net service support
-a, –raw disable reformatting of the query
-i, –display-redirections display all redirects instead of hiding them
-p PORT, –port=PORT use port number PORT (in conjunction with HOST)
-r, –rwhois force an rwhois query to be made
–rwhois-display=DISPLAY sets the display option in rwhois queries
–rwhois-limit=LIMIT sets the maximum number of matches to return

Example: whois google.com

This will return all the available information about the domain google.com

* Note that there are many versions of the whois command so before you use it consult the man page

What is the nslookup command?

May 18, 08 by the programmer

NSLOOKUP (Name Server Lookup)

is a command that it is used to query DNS (Domain Name System) servers and is embedded in Windows and Unix operating systems. Although nslookup exists in both UNIX and Windows, there are some differences in the way that it behaves in the two operating systems.

This command can be found in the BIND (Berkeley Internet Name Domain) package, the most commonly used DNS server on the Internet, especially on Unix operating systems.

The nslookup can be used to find various details relating to DNS including IP addresses of a particular computer, MX records for a domain or the NS servers of a domain - all using DNS lookups

The following examples are done on Windows platform.

NSLOOKUP common usage

You can use nslookup command by

  • calling it directly or
  • entering the nslookup shell

Direct usage of nslookup

In this example I will try to find out the IP address of my domain using the nslookup directly without entering its shell.

In order to do that I will write the following :

C:\>nslookup minanov.com
Server: locac dns server domain name
Address:
locac dns server IP Address

Non-authoritative answer:
Name: minanov.com
Address: 64.72.119.195

The first two rows in the command colored with light blue are showing the local network DNS server. This information is not correct.

However the other text bellow non-authoritative answer shows the name of the domain and the IP address of the server.

Using nslookup from it’s shell

Note that nslookup is a command that has a lot of possibilities. By entering in the shell all of this possibilities are available.

To enter the nslookup shell all you have to do is write “nslookup on the command prompt. If you want to find out more about all the possibilities just write “?” in the shell and hit enter. All of the available options will be displayed.

C:\>nslookup
>

Note that there is a more modern version of the nslookup command.

The command that will probably replace nslookup is the “dig” program, also embedded in the BIND package. However the dig command is not embedded in Windows operating systems yet. At least not in Windows XP.

Converting a normal IP Address to IP Long/decimal Format?

May 17, 08 by the programmer

IP addresses are expressed in dotted-decimal format - basically 4 sets of numbers from 0 to 255 seperated by periods

Another way of expressing an IP address is in a Long or Decimal 10 digit number format.

The decimal representation of the IP address is used because it is very easy to compare ranges of ip adresses that way.

So instead of comparing 192.168.1.1 to 192.168.1.255

it is much easier to compare 3232235777 to 3232236031

How is the decimal IP number generated from an IP address in a dotted format?

We will convert the IP address 192.168.0.1 from a dotted format to a decimal 10 digit format.

A.B.C.D = D + (C * 256) + (B * 256 * 256) + (A * 256 * 256 * 256) =

192.168.0.1 = 1 + (0 * 256) + (168 * 256 * 256) + (192 * 256 * 256 * 256) = 3232235521

This is a PHP function that will do that for you.

function ip_address_to_number($IPaddress) {

if ($IPaddress == “”) {

return 0;

} else {

$ips = split (\., “$IPaddress”);

return ($ips[3] + $ips[2] * 256 + $ips[1] * 256 * 256 + $ips[0] * 256 * 256 * 256);

}

}

Wait wait…

There is a much easier way of doing that in PHP. There is a already built in function in php just for that it’s called ip2long(). Check it out.

This applies only for IP v4 IP addresses

Have a nice conversion :)