ipisp provides a Go client for Team Cymru's IP-ASN mapping service. Basically, this library allows you to query an IP address' ISP and allocation information.
go get github.com/ammario/ipisp/v2
- 0 external dependencies
- Bulk and single lookups
- Query ISP name, ASN, country, registry and CIDR range
Running
resp, err := ipisp.LookupIP(context.Background(), net.ParseIP("4.2.2.2"))
if err != nil {
log.Fatalf("lookup: %v", err)
}
fmt.Printf("ISP: %s\n", resp.ISPName)
displays
ISP: LEVEL3, US