SkillPilotAI

whois (Linux and macOS)

whois tells you who is responsible for a domain, an IP block or an AS number: registrar, dates, name servers, organisation and abuse contact. It is a one-line text query on TCP port 43, and the client follows referrals from IANA to the right registry, RIR or registrar.

89.1 Why is it used?

  • Domain: expiry date, registrar, name servers (e.g. while debugging a domain that stopped resolving).
  • IP: which organisation owns the block and where to report abuse from an attacking IP.
  • AS number: the network name and the routes it announces.
  • Linux: apt / dnf / apk install whois (standard client, guesses the right server). macOS: built-in BSD whois with different flags. Windows: Sysinternals whois or WSL.

89.2 How it works: the referral chain

Domain: registry to registrar
  1. 1.whois example.com: the client knows .com lives with Verisign

  2. 2.Query on TCP 43 to whois.verisign-grs.com

  3. 3.Registry answer: expiry date, name servers, "Registrar WHOIS Server: whois.iana.org"

  4. 4.Client follows the referral and queries the registrar's server (here IANA itself)

IP / AS: IANA to the RIR
  1. 1.whois -I 8.8.8.8: first query to whois.iana.org

  2. 2.IANA: "refer: whois.arin.net" (8.0.0.0 block belongs to ARIN)

  3. 3.Query to ARIN: NetRange, OrgName Google LLC, abuse email

  4. 4.European IP -> RIPE, Asian IP -> APNIC (same pattern)

89.3 General options (Linux whois 5.5.23)

Terminal
whois --verbose example.comwhois example.com | wc -lwhois -H example.com | wc -lwhois -H example.com | grep -i expirwhois --no-recursion example.comwhois --verbose -I 8.8.8.8whois AS15169
Output
$ whois --verbose example.comUsing server whois.verisign-grs.com.   Registrar WHOIS Server: whois.iana.org   Registry Expiry Date: 2027-08-13T04:00:00Z   Registrar: RESERVED-Internet Assigned Numbers Authority   Name Server: ELLIOTT.NS.CLOUDFLARE.COM   Name Server: HERA.NS.CLOUDFLARE.COMUsing server whois.iana.org.Query string: "example.com"organisation: Internet Assigned Numbers Authority$ whois example.com | wc -l67$ whois -H example.com | wc -l41$ whois -H example.com | grep -i expir   Registry Expiry Date: 2027-08-13T04:00:00Z$ whois --verbose -I 8.8.8.8Using server whois.iana.org.refer:        whois.arin.netUsing server whois.arin.net.Query string: "n + 8.8.8.8"NetRange:       8.8.8.0 - 8.8.8.255OrgName:        Google LLC$ whois AS15169ASNumber:       15169ASName:         GOOGLEOrgAbuseEmail:  network-abuse@google.com
  • --verbose shows which server is queried (Verisign first, then IANA).
  • -H hides legal disclaimers (67 -> 41 lines); --no-recursion skips the second query to the registrar.
  • -I starts at IANA and follows the refer line.

89.4 Choosing the server: -h, -p, --

Lab whois server 192.168.109.43 (socat on TCP 43 and 4343) prints the query it receives, so you can see exactly what the client sends.

Terminal
whois -h 192.168.109.43 shop.labwhois -p 4343 -h 192.168.109.43 shop.labwhois -h 192.168.109.43 -- -B shop.labwhois -h 192.168.109.43 -r -B shop.lab
Output
$ whois -h 192.168.109.43 shop.lab% n089 lab whois server (port 43)% query received: "shop.lab"domain:     shop.labregistrar:  n089 Lab Registrarexpires:    2027-11-09$ whois -p 4343 -h 192.168.109.43 shop.lab% n089 lab whois server (port 4343)% query received: "shop.lab"$ whois -h 192.168.109.43 -- -B shop.lab% n089 lab whois server (port 43)% query received: "-B shop.lab"$ whois -h 192.168.109.43 -r -B shop.labWarning: RIPE flags used with a traditional server.% query received: "-r -B shop.lab"
OptionMeaning
OBJECTDomain, IP, network, AS number or handle
-h HOST / -p PORTQuery this server / port (default 43)
-HHide legal disclaimers
-IStart at IANA and follow referrals
--no-recursionDo not follow the registrar referral
--verboseShow the server and the exact query string
-- ...Send everything after it to the server unchanged
--help / --versionHelp / version (5.5.23)
WHOIS_OPTIONS / WHOIS_SERVEREnv: default options / fallback server
/etc/whois.confRegex -> server map

89.5 RIPE-style server flags

Servers like whois.ripe.net, whois.radb.net understand extra flags; the Linux client passes them through (and warns when the server is a traditional one).

Terminal
whois --verbose -h whois.ripe.net 8.8.8.8whois -h whois.ripe.net -s ARIN-GRS \  -b 8.8.8.8whois -h whois.ripe.net -s ARIN-GRS \  -r -K -L 8.8.8.0/24whois -h whois.ripe.net -s ARIN-GRS \  -r -K -x 8.8.8.0/24whois -h whois.ripe.net -s ARIN-GRS \  -r -l 8.8.8.0/24
Output
$ whois --verbose -h whois.ripe.net 8.8.8.8Using server whois.ripe.net.Query string: "-V Md5.5.23 8.8.8.8"inetnum:        6.0.0.0 - 9.128.255.255netname:        NON-RIPE-NCC-MANAGED-ADDRESS-BLOCK$ whois -h whois.ripe.net -s ARIN-GRS 8.8.8.8inetnum:        8.8.8.0 - 8.8.8.255org:            GOGLsource:         ARIN-GRS$ whois -h whois.ripe.net -s ARIN-GRS -b 8.8.8.8inetnum:        8.8.8.0 - 8.8.8.255$ whois -h whois.ripe.net -s ARIN-GRS -r -K -L 8.8.8.0/24inetnum:        8.8.8.0 - 8.8.8.255$ whois -h whois.ripe.net -s ARIN-GRS -r -K -x 8.8.8.0/24inetnum:        8.8.8.0 - 8.8.8.255$ whois -h whois.ripe.net -s ARIN-GRS -r -l 8.8.8.0/24%ERROR:101: no entries found
Terminal
whois -h whois.ripe.net -q sourceswhois -h whois.ripe.net -q typeswhois -h whois.ripe.net -t inetnumwhois --verbose -h whois.radb.net \  -K -T route -i origin AS15169whois -h whois.radb.net -- \  '-i origin AS15169' | grep -cE '^route6?:'whois -h whois.cymru.com ' -v 8.8.8.8'
Output
$ whois -h whois.ripe.net -q sourcesRIPE:3:N:0-0APNIC-GRS:3:N:0-0ARIN-GRS:3:N:0-0RADB-GRS:3:N:0-0$ whois -h whois.ripe.net -q typesinetnum inet6num as-block aut-num as-set route route6 route-set inet-rtr filter-set peering-set rtr-set domain poetic-form poem mntner irt key-cert organisation role person$ whois -h whois.ripe.net -t inetnuminetnum:        [mandatory]  [single]     [primary/lookup key]netname:        [mandatory]  [single]     [lookup key]descr:          [optional]   [multiple]   [ ]country:        [mandatory]  [multiple]   [ ]$ whois --verbose -h whois.radb.net -K -T route -i origin AS15169Warning: RIPE flags used with a traditional server.Query string: "-K -T route -i origin as15169"route: 8.8.4.0/24origin: AS15169route: 8.8.8.0/24origin: AS15169$ whois -h whois.radb.net -- '-i origin AS15169' | grep -cE '^route6?:'4013$ whois -h whois.cymru.com ' -v 8.8.8.8'AS      | IP               | BGP Prefix          | CC | Registry | Allocated  | AS Name15169   | 8.8.8.8          | 8.8.8.0/24          | US | arin     | 2023-12-28 | GOOGLE - Google LLC, US
FlagMeaning
-s SRC / -aSearch one mirrored source (e.g. ARIN-GRS) / all mirrored databases
-b / -KBrief: range + abuse contact / primary keys only
-l / -LParent: one level / all levels
-m / -MChild ranges: one level / all
-xExact prefix match
-i ATTR VALUE / -T TYPEInverse search (e.g. origin AS15169) / limit to object type (route)
-q sources|types|versionServer info
-t TYPE / -v TYPEObject template / verbose template
-r / -R / -B / -GNo contact lookups / local copy, ignore referral / no email filtering / no grouping
-c, -d, -g SRC:F-LSmallest range with irt, include reverse DNS domain, updates between serials (mirroring)

89.6 macOS whois options

macOS ships a BSD whois whose letters mostly select a database. It could not run in the lab, so the macOS syntax is shown and the same servers were queried from Linux:

Terminal
# macOS (BSD whois), syntax onlywhois -a 8.8.8.8whois -I example.comwhois -Q example.comwhois -m AS15169# same servers from the Linux lab (real)whois -h whois.arin.net 8.8.8.8whois -h whois.iana.org example.comwhois -h whois.verisign-grs.com example.comwhois -h whois.radb.net AS15169
Output
$ whois -h whois.arin.net 8.8.8.8NetRange:       8.8.8.0 - 8.8.8.255OrgName:        Google LLC$ whois -h whois.iana.org example.comdomain:       EXAMPLE.COMorganisation: Internet Assigned Numbers Authority$ whois -h whois.verisign-grs.com example.com   Registry Expiry Date: 2027-08-13T04:00:00Z   Registrar: RESERVED-Internet Assigned Numbers Authority$ whois -h whois.radb.net AS15169aut-num:        AS15169as-name:        Google
macOS optionMeaningLinux equivalent
-a / -AARIN / APNIC database-h whois.arin.net / -h whois.apnic.net
-I / -rIANA / RIPE database-I or -h whois.iana.org / -h whois.ripe.net
-m / -PRADB / PeeringDB-h whois.radb.net
-f / -l / -kAfriNIC / LACNIC / KRNIC-h <that server>
-i, -g, -bInterNIC, US .GOV, Abuse Clearinghouse-h <that server>
-c TLDTLD.whois-servers.net (ccTLD servers)-h <tld server>
-Q / -RQuick (no referrals) / recursive--no-recursion / default
-S, -h host, -p portRaw query, server, port--, -h, -p
WHOIS_SERVER, RA_SERVEREnv: primary / secondary serverWHOIS_SERVER

89.7 Common mistakes

  • Expecting the owner's name, email and phone: since GDPR most domain contacts are REDACTED; reach the owner via the registrar's abuse contact or web form.
  • Asking RIPE about a non-RIPE IP and reading "NON-RIPE-NCC-MANAGED-ADDRESS-BLOCK" as the owner: use -I or the right RIR (or -s ARIN-GRS on RIPE).
  • Sending RIPE flags to a traditional server: the client warns and the server may ignore them.
  • Using Linux flags on macOS (or the other way round): the letters mean different things.

89.8 Interview tips

  • whois = plain-text protocol on TCP 43 (RFC 3912); the client follows IANA -> registry / RIR -> registrar referrals.
  • To report an attacking IP look for OrgAbuseEmail / abuse-mailbox; in the RIPE region whois -b returns range + abuse contact.
  • RDAP is the modern replacement: same data as JSON over HTTPS.
  • IP-to-ASN in one line: whois -h whois.cymru.com ' -v IP'; routes of an AS: whois -h whois.radb.net -i origin ASN.