geoip — geolocate an IP address or a hostname
SYNOPSIS
geoip [ip | hostname]
DESCRIPTION
Prints the approximate location of an IPv4 or IPv6 address: city, region, country, continent, coordinates (with a map link) and time zone, plus the network that owns it (ISP, organization, AS number). A hostname is first resolved to its IP address. Without an argument, geoip locates your own public IP address.
HOW IT WORKS
A hostname is resolved over DNS-over-HTTPS (dns.google), A record first, then AAAA. The address is then looked up on ipwho.is; if that service is unreachable, ipapi.co is tried instead. Both are called directly from your browser over HTTPS. Private and reserved addresses (192.168.x.x, 10.x.x.x, 127.0.0.1, fe80::…) are recognized locally: they have no public location, so nothing is sent.
USE CASES
- find where a server is hosted, and by which provider;
- check the country and network behind an IP address seen in a log;
- see the time zone of a remote host before scheduling maintenance.
NOTES
IP geolocation is approximate: it usually points to the provider's network hub, not to a street address, and two services may disagree on the city. Behind a CDN (Cloudflare, Fastly…), a hostname resolves to the CDN's nearest edge, not to the origin server.
EXAMPLES
geoip geoip 8.8.8.8 geoip 2606:4700:4700::1111 geoip github.com