{"id":18542517,"url":"https://github.com/pulsejet/geoipns","last_synced_at":"2026-02-26T07:04:19.981Z","repository":{"id":93822325,"uuid":"216356684","full_name":"pulsejet/geoipns","owner":"pulsejet","description":"High performance DNS server to locate IP addresses","archived":false,"fork":false,"pushed_at":"2020-11-29T06:31:18.000Z","size":52,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-01T19:36:53.219Z","etag":null,"topics":["asn","dns","dns-server","geoip2","geolocation","golang","subnet"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pulsejet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-20T12:15:37.000Z","updated_at":"2024-03-20T08:30:03.000Z","dependencies_parsed_at":"2023-04-19T17:47:17.723Z","dependency_job_id":null,"html_url":"https://github.com/pulsejet/geoipns","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/pulsejet/geoipns","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pulsejet%2Fgeoipns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pulsejet%2Fgeoipns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pulsejet%2Fgeoipns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pulsejet%2Fgeoipns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pulsejet","download_url":"https://codeload.github.com/pulsejet/geoipns/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pulsejet%2Fgeoipns/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29851221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T22:37:40.667Z","status":"online","status_checked_at":"2026-02-26T02:00:06.774Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asn","dns","dns-server","geoip2","geolocation","golang","subnet"],"created_at":"2024-11-06T20:09:02.498Z","updated_at":"2026-02-26T07:04:19.962Z","avatar_url":"https://github.com/pulsejet.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GeoIPNS\n\nMake DNS queries to get the geolocation and ASN name of an IP address. You can read the original blog post about why this project exists [here](https://medium.com/@varunpp2/locating-ip-addresses-with-dns-queries-af54228ea29c).\n\n[![Build Status](https://travis-ci.org/pulsejet/geoipns.svg?branch=master)](https://travis-ci.org/pulsejet/geoipns)\n[![codecov](https://codecov.io/gh/pulsejet/geoipns/branch/master/graph/badge.svg)](https://codecov.io/gh/pulsejet/geoipns)\n[![Go Report Card](https://goreportcard.com/badge/github.com/pulsejet/geoipns)](https://goreportcard.com/report/github.com/pulsejet/geoipns)\n[![GitHub license](https://img.shields.io/github/license/pulsejet/geoipns)](https://github.com/pulsejet/geoipns/blob/master/LICENSE)\n\n## Usage\n\nMake a `TXT` query for `IP.geoipns` to the server to get the location and ASN name of `IP` in an [RFC 1464](https://tools.ietf.org/html/rfc1464) compliant format. The model can be easily extended to store arbitrary data about IP subnets using the configuration file.\n\nTo build and run,\n```shell\ngo get github.com/pulsejet/geoipns \u0026\u0026 cd $GOPATH/src/github.com/pulsejet/geoipns\ndep ensure  # you may skip this step if deps are obtained automatically\ngo build\n./getdata.sh  # write your custom script to get GeoIP data\n./geoipns\n```\n\nTo query,\n```shell\n$ dig +short @localhost -p5312 -tTXT 3.105.177.255.geoipns\n\"location=Sydney, NSW, AU\"\n\"asn=Amazon.com, Inc.\"\n```\n\n## Data Structure\nEach subnet is stored as an IP range with start and end 128-bit IP addresses. All data points are stored together as an array sorted by the IP address, with a high/low boolean. The data structure is looked up using binary search to find the location of the queried IP address. If a low IP precedes the discovered location, the IP is contained in the corresponding range; if a high IP precedes then the IP is contained in the parent range (if existent). Each data point stores information about the complementary point and the parent range.\n\n## Example Data Structure\nThe following CSV (with proper configuration)\n\n| cidr            | start_ip       | end_ip         | location     |\n|-----------------|----------------|----------------|--------------|\n| 10.105.0.0/16   |                |                | OuterIPRange |\n| 10.105.177.0/24 |                |                | Subnet1      |\n|                 | 10.105.177.120 | 10.105.177.200 | Subnet11     |\n|                 | 10.105.177.120 | 10.105.177.128 | Subnet12     |\n|                 | 10.105.200.0   | 10.105.201.255 | Subnet2      |\n\nwould produce the following data structure (note that all IP addresses are internally represented as 128-bit bytes slices)\n\n| Address | IP             | IsHigh | Data         | Complement | Parent |\n|---------|----------------|--------|--------------|------------|--------|\n| 0x001   | 10.105.0.0     | false  | OuterIPRange | 0x010      | 0x000  |\n| 0x002   | 10.105.177.0   | false  | Subnet1      | 0x007      | 0x001  |\n| 0x003   | 10.105.177.120 | false  | Subnet11     | 0x006      | 0x002  |\n| 0x004   | 10.105.177.120 | false  | Subnet12     | 0x005      | 0x003  |\n| 0x005   | 10.105.177.128 | true   | Subnet12     | 0x004      | 0x003  |\n| 0x006   | 10.105.177.200 | true   | Subnet11     | 0x003      | 0x002  |\n| 0x007   | 10.105.177.255 | true   | Subnet1      | 0x002      | 0x001  |\n| 0x008   | 10.105.200.0   | false  | Subnet2      | 0x009      | 0x001  |\n| 0x009   | 10.105.201.255 | true   | Subnet2      | 0x008      | 0x001  |\n| 0x010   | 10.105.255.255 | true   | OuterIPRange | 0x001      | 0x000  |\n\n## Testing\nUse `go test -v ./...` to run automated tests.\n\n## Benchmark\nTesting GeoIPNS running on an LXC container limited to 4 vCPUs and 4GB RAM on a `24 x Intel(R) Xeon(R) CPU E5-2620 v2 @ 2.10GHz` machine with PHP7.3 on the same machine for 10000 randomized IPv4 requests gave the following results:\n```text\nAverage 433μs per GeoIPNS request (native DNS client + PHP, different container)\nAverage 229μs per GeoIPNS request (phpdns, different container)\nAverage 150μs per GeoIPNS request (singe-threaded C++, same container)\nAverage 94μs per GeoIPNS request (goroutines, same container)\n```\n\n## Docker\n\n\u003e Since the GeoLite database cannot be downloaded directly any more, you will have to write your own script replacing getdata.sh to download the GeoIP database as a CSV. The `getdata.sh` and `Dockerfile` files are kept in the repository for historical purposes only.\n\nTwo environment variables can be set:\n* `SUFFIX`: the DNS suffix to listen on\n* `INTRANET_CSV_URL`: a URL pointing to a CSV file with location entries other than GeoIP2 lite\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpulsejet%2Fgeoipns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpulsejet%2Fgeoipns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpulsejet%2Fgeoipns/lists"}