Skip to content

rvido/NetOrigin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NetOrigin

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

Requirements

  • Rust toolchain with Cargo
  • Network access for live lookups
  • IPINFO_TOKEN environment variable when using --ip

Build

cargo check

Test

cargo test

Usage

cargo run -- --google
cargo run -- --company telegram
cargo run -- --company telegram --asnums
cargo run -- --asn AS15169
cargo run -- --ip 8.8.8.8

You can also pass the ASN without the AS prefix:

cargo run -- --asn 15169

For 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.com

Library Usage

NetOrigin 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_ranges
  • get_as_numbers_of
  • get_ip_ranges_of
  • get_ip_ranges_for_asn
  • lookup_ipinfo
  • from_ipnet / to_ipnet

Notes

  • The --company, --asn, and --google flows rely on public third-party endpoints and page structure.
  • The --ip flow 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.

Project Structure

  • src/lib.rs: library entry point that exports ipranges
  • src/cli.rs: CLI argument parsing with clap
  • src/main.rs: command dispatch and terminal output
  • src/ipranges.rs: HTTP requests, scraping, IP range aggregation, and IPinfo lookup logic

License

This project is licensed under the MIT License. See LICENSE.

About

NetOrigin is a small Rust CLI for retrieving network ownership data and IP ranges.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages