- How to Get Domain and IP Address Information Using WHOIS Command
- How to Find IP Address Information
- How to Find Domain Information
- Whois in linux with examples
- EXAMPLES
- Check domain name availability with bash and whois
- Install whois on major Linux distros
- How to check for domain availability
- Check domain availability with Bash script
- Closing Thoughts
- Related Linux Tutorials:
How to Get Domain and IP Address Information Using WHOIS Command
WHOIS is a TCP-based query and response protocol that is commonly used to provide information services to Internet users. It returns information about the registered Domain Names, an IP address block, Name Servers and a much wider range of information services.
In Linux, the whois command line utility is a WHOIS client for communicating with the WHOIS server (or database host) which listen to requests on the well-known port number 43, which stores and delivers database content in a human-readable format.
whois command line utility does not come pre-installed on many Linux distributions, run the appropriate command below for your distribution to install it.
# yum install whois #RHEL/CentOS # dnf install whois #Fedora 22+ $ sudo apt install whois #Debian/Ubuntu
How to Find IP Address Information
To get the information about specific IP Address issue the command as shown in the below example.
$ whois 216.58.206.46 # # ARIN WHOIS data and services are subject to the Terms of Use # available at: https://www.arin.net/whois_tou.html # # If you see inaccuracies in the results, please report at # https://www.arin.net/public/whoisinaccuracy/index.xhtml # # # The following results may also be obtained via: # https://whois.arin.net/rest/nets;q=216.58.206.46?showDetails=true&showARIN=false&showNonArinTopLevelNet=false&ext=netref2 # NetRange: 216.58.192.0 - 216.58.223.255 CIDR: 216.58.192.0/19 NetName: GOOGLE NetHandle: NET-216-58-192-0-1 Parent: NET216 (NET-216-0-0-0-0) NetType: Direct Allocation OriginAS: AS15169 Organization: Google LLC (GOGL) RegDate: 2012-01-27 Updated: 2012-01-27 Ref: https://whois.arin.net/rest/net/NET-216-58-192-0-1 OrgName: Google LLC OrgId: GOGL Address: 1600 Amphitheatre Parkway City: Mountain View StateProv: CA PostalCode: 94043 Country: US RegDate: 2000-03-30 Updated: 2017-12-21 Ref: https://whois.arin.net/rest/org/GOGL .
How to Find Domain Information
To get the information about the registered domain, simply issue the following command with the domain name. It will retrieve domain data including availability, ownership, creation, expiration details, name servers, etc.
$ whois google.com Domain Name: GOOGLE.COM Registry Domain ID: 2138514_DOMAIN_COM-VRSN Registrar WHOIS Server: whois.markmonitor.com Registrar URL: http://www.markmonitor.com Updated Date: 2011-07-20T16:55:31Z Creation Date: 1997-09-15T04:00:00Z Registry Expiry Date: 2020-09-14T04:00:00Z Registrar: MarkMonitor Inc. Registrar IANA ID: 292 Registrar Abuse Contact Email: [email protected] Registrar Abuse Contact Phone: +1.2083895740 Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited Domain Status: serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited Domain Status: serverTransferProhibited https://icann.org/epp#serverTransferProhibited Domain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited Name Server: NS1.GOOGLE.COM Name Server: NS2.GOOGLE.COM Name Server: NS3.GOOGLE.COM Name Server: NS4.GOOGLE.COM .
The formatting of information will differ based on the WHOIS server used. In addition, one downside of WHOIS is the lack of full access to the data, therefore check out these useful guides for querying DNS information in Linux:
If you have any queries or information about the article that you want to share with us, use the comment form below.
Whois in linux with examples
The utility looks up records in the databases maintained by several Network Information Centers ( NICs )
The options are as follows:
-a Use the American Registry for Internet Numbers ( ARIN ) database. It contains network numbers used in those parts of the world covered neither by APNIC , AfriNIC , LACNIC nor by RIPE
(Hint: All point of contact handles in the ARIN whois database end with Qq Li -ARIN . )
-A Use the Asia/Pacific Network Information Center ( APNIC ) database. It contains network numbers used in East Asia, Australia, New Zealand, and the Pacific islands. -b Use the Network Abuse Clearinghouse database. It contains addresses to which network abuse should be reported, indexed by domain name. -c country-code This is the equivalent of using the — h option with an argument of Qq Ar country-code Ns Li .whois-servers.net . -d Use the US Department of Defense database. It contains points of contact for subdomains of .MIL -f Use the African Network Information Centre ( AfriNIC ) database. It contains network numbers used in Africa and the islands of the western Indian Ocean. -g Use the US non-military federal government database, which contains points of contact for subdomains of .GOV -h host Use the specified host instead of the default variant. Either a host name or an IP address may be specified.
By default constructs the name of a whois server to use from the top-level domain ( TLD ) of the supplied (single) argument, and appending Qq Li .whois-servers.net . This effectively allows a suitable whois server to be selected automatically for a large number of TLDs
In the event that an IP address is specified, the whois server will default to the American Registry for Internet Numbers ( ARIN ) If a query to ARIN references APNIC , AfriNIC , LACNIC or RIPE that server will be queried also, provided that the — Q option is not specified.
If the query is not a domain name or IP address, will fall back to whois.crsnic.net -i Use the Network Solutions Registry for Internet Numbers (whois.networksolutions.com ) database. It contains network numbers and domain contact information for most of .COM , .NET , .ORG and .EDU domains.
NOTE The registration of these domains is now done by a number of independent and competing registrars and this database holds no information on the domains registered by organizations other than Network Solutions, Inc. Also, note that the InterNIC database (whois.internic.net ) is no longer handled by Network Solutions, Inc. For details, see http://www.internic.net/
(Hint: Contact information, identified by the term handle can be looked up by prefixing Qq Li handle to the NIC handle in the query.) -I Use the Internet Assigned Numbers Authority ( IANA ) database. It contains network information for top-level domains. -k Use the National Internet Development Agency of Korea’s ( KRNIC ) database. It contains network numbers and domain contact information for Korea. -l Use the Latin American and Caribbean IP address Regional Registry ( LACNIC ) database. It contains network numbers used in much of Latin America and the Caribbean. -m Use the Route Arbiter Database ( RADB ) database. It contains route policy specifications for a large number of operators’ networks. -p port Connect to the whois server on port If this option is not specified, defaults to port 43. -Q Do a quick lookup. This means that will not attempt to lookup the name in the authoritative whois server (if one is listed). This option has no effect when combined with any other options. -r Use the R´eseaux IP Europ´eens ( RIPE ) database. It contains network numbers and domain contact information for Europe. -R Use the Russia Network Information Center ( RIPN ) database. It contains network numbers and domain contact information for subdomains of .RU This option is deprecated; use the — c option with an argument of Qq Li RU instead. -6 Use the IPv6 Resource Center ( 6bone ) database. It contains network names and addresses for the IPv6 network.
The operands specified to are treated independently and may be used as queries on different whois servers.
EXAMPLES
Most types of data, such as domain names and IP addresses, can be used as arguments to without any options, and will choose the correct whois server to query. Some exceptions, where will not be able to handle data correctly, are detailed below.
To obtain contact information about an administrator located in the Russian TLD domain Qq Li RU , use the — c option as shown in the following example, where CONTACT-ID is substituted with the actual contact identifier.
(Note: This example is specific to the TLD Qq Li RU , but other TLDs can be queried by using a similar syntax.)
The following example demonstrates how to obtain information about an IPv6 address or hostname using the — 6 option, which directs the query to 6bone
The following example demonstrates how to query a whois server using a non-standard port, where « query-data » is the query to be sent to « whois.example.com » on port « rwhois » (written numerically as 4321).
Check domain name availability with bash and whois
If you’ve ever tried to come up with a catchy domain name, you know how annoying it can be to keep checking to see if a certain name is available. Fortunately, on Linux we can make the task a little easier on us by using the whois command. When a domain is available, the output from whois will let us know that it’s not able to find any information for that domain.
It’s easy enough then to put this functionality into a Bash script, which helps to automate checking lots of different TLDs (Top Level Domains, like .com, .net, .org, etc).
In this guide, we’ll show how to check domain name availability from the command line on Linux. Then, we’ll give you a simple Bash script that you can copy onto your own system and check for lots of domains at once. Read on to learn how.
In this tutorial you will learn:
- How to install whois on major Linux distros
- How to check for domain name availability with whois command
- Bash script for checking domain name availability
Category | Requirements, Conventions or Software Version Used |
---|---|
System | Any Linux distro |
Software | whois |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions | # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command $ – requires given linux commands to be executed as a regular non-privileged user |
Install whois on major Linux distros
In order to check domain availability from the command line, you’ll need to have access to the whois command. Use the appropriate command below to install the whois utility with your system’s package manager.
To install whois on Ubuntu, Debian, and Linux Mint:
Once it’s installed, you’ll be able to use the example commands below and the Bash script to check for domain availability.
How to check for domain availability
Check to see if a domain is registered to anyone by simply using the whois command and specifying a domain name.
If the domain is taken, you’ll see output like that in the screenshot above. It lists when the domain was registered, when it expires, the registrar, and various other registry information.
Contrast that to the output below, where the domain is available and returns a “No match found for” message.
It’s nice being able to check domain availability from the Linux command line. However, it’s not that much more convenient than just checking it in some registrar website. The real convenience can be found by using the Bash script in the section below.
Check domain availability with Bash script
Start by saving the following script to an empty file on your computer.
#!/bin/bash # Name: Check for domain name availability # linuxconfig.org # Please copy, share, redistribute and improve if [ "$#" == "0" ]; then echo "You need tu supply at least one argument!" exit 1 fi DOMAINS=( '.com' '.co.uk' '.net' '.info' '.mobi' \ '.org' '.tel' '.biz' '.tv' '.cc' '.eu' '.ru' \ '.in' '.it' '.sk' '.com.au' ) ELEMENTS=$ while (( "$#" )); do for (( i=0;i<$ELEMENTS;i++)); do whois $1$]> | egrep -q \ '^No match|^NOT FOUND|^Not fo|AVAILABLE|^No Data Fou|has not been regi|No entri' if [ $? -eq 0 ]; then echo "$1$]> : available" fi done shift done
After you save the script, give it execute permissions.
And then run the script and specify it a domain name you’d like to check for.
As you can see in the screenshot above, the output gives us a list of TLDs that are available for our search string. You can also specify more than one query if you want to look up multiple website names.
You can adapt the script as needed, if you want to check for additional TLDs or add more “no match” type of messages to it.
Closing Thoughts
In this guide, we learned how to check for domain name availability from the Linux command line. This is done through the whois tool, but isn’t a lot more convenient than using a registrar website to do the same thing. However, with a bit of Bash scripting, we see a sharp increase in efficiency and convenience for this task. Now checking for domain names is easier than ever.
Related Linux Tutorials:
Comments and Discussions