We rely on IP location for many things as sysadmins, like checking where that flood of logins to wordpress is coming from (China?!). Or even checking if a new order is coming from downtown Dubai or from the outskirts of Jakarta…
I usually use ip2location.com/demo/
#!/bin/bash
ADDR=$1
KEY=GETYOURKEYFROMhttp://db-ip.com/api/#key
wget -qO- "http://api.db-ip.com/addrinfo?addr=${ADDR}&api_key=${KEY}"
Here’s a sample session:
$ ipinfo 199.59.150.7
{"address":"199.59.150.7","country":"US","stateprov":"California","city":"San Francisco"}
Very simple, but seems enough if I want to check the IP location from the shell. Maybe I’ll add more features (if I need them!)
No Comments
You can leave the first : )