NetOrigin is a small Rust project for retrieving network ownership data and IP ranges.
It can be used as:
- A CLI tool
- A reusable library crate (
netorigin::ipranges)
It supports:
- Google service IP ranges from Google's published JSON feeds
- Company-to-ASN lookup via
bgp.he.net - Company-to-IP-range aggregation via
bgp.he.net - ASN-to-IP-range lookup via
bgp.he.net - IP-to-ASN ownership lookup via IPinfo
- Rust toolchain with Cargo
- Network access for live lookups
IPINFO_TOKENenvironment variable when using--ip
cargo checkcargo testcargo run -- --google
cargo run -- --company telegram
cargo run -- --company telegram --asnums
cargo run -- --asn AS15169
cargo run -- --ip 8.8.8.8You can also pass the ASN without the AS prefix:
cargo run -- --asn 15169For IPinfo lookups, export a token first:
export IPINFO_TOKEN=your_token_here
cargo run -- --ip 8.8.8.8
IPinfo lookup for '8.8.8.8':
ASN: AS15169
Name: Google LLC
Domain: google.comNetOrigin also exposes IP range functionality through a library module.
use netorigin::ipranges;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let as_numbers = ipranges::get_as_numbers_of("telegram")?;
println!("Found {} AS numbers", as_numbers.len());
let ip_ranges = ipranges::get_ip_ranges_for_asn("AS15169")?;
println!("Found {} IP ranges", ip_ranges.len());
Ok(())
}Available library entry points include:
get_google_ip_rangesget_as_numbers_ofget_ip_ranges_ofget_ip_ranges_for_asnlookup_ipinfofrom_ipnet/to_ipnet
- The
--company,--asn, and--googleflows rely on public third-party endpoints and page structure. - The
--ipflow uses IPinfo and falls back from the Core lookup endpoint to the Lite endpoint when the token does not have Core access. - Deterministic unit tests cover local parsing logic, but some tests and runtime commands still depend on live network access.
src/lib.rs: library entry point that exportsiprangessrc/cli.rs: CLI argument parsing withclapsrc/main.rs: command dispatch and terminal outputsrc/ipranges.rs: HTTP requests, scraping, IP range aggregation, and IPinfo lookup logic
This project is licensed under the MIT License. See LICENSE.