Skip to main content

IpNetwork

Represents IP network allocation information returned from RDAP queries for IP addresses and CIDR blocks.
object_class_name
string
Always “ip network” for IP network objects
conformance
array<string>
RDAP conformance levels (e.g., ["rdap_level_0"])
notices
array<Notice>
Server notices and terms of service. See common fields
handle
string
Registry-unique identifier for the network allocation
let net_handle = network.handle.unwrap_or_default();
start_address
string
First IP address in the network range
if let Some(start) = &network.start_address {
    println!("Network starts at: {}", start);
}
end_address
string
Last IP address in the network range
if let Some(end) = &network.end_address {
    println!("Network ends at: {}", end);
}
ip_version
string
IP version: “v4” or “v6”
match network.ip_version.as_deref() {
    Some("v4") => println!("IPv4 network"),
    Some("v6") => println!("IPv6 network"),
    _ => println!("Unknown version"),
}
name
string
Network name or identifier
network_type
string
Type of allocation (e.g., “ALLOCATED”, “ASSIGNED”)
country
string
ISO 3166-1 alpha-2 country code
if let Some(country) = &network.country {
    println!("Allocated to: {}", country);
}
parent_handle
string
Handle of the parent network allocation
status
array<string>
Network status values (e.g., “active”, “reserved”)
entities
array<Entity>
Related entities (registrants, abuse contacts, etc.). See Entity
// Find abuse contact
let abuse = network.entities.iter()
    .find(|e| e.roles.contains(&"abuse".to_string()))
    .and_then(|e| e.vcard.as_ref())
    .and_then(|v| v.email());

if let Some(email) = abuse {
    println!("Abuse contact: {}", email);
}
remarks
array<Remark>
Informational remarks. See common fields
Related links (self, related resources). See common fields
port43
string
WHOIS server hostname for port 43 queries
events
array<Event>
Lifecycle events (allocation, last changed, etc.). See common fields
// Find allocation date
let allocated = network.events.iter()
    .find(|e| e.action == "registration" || e.action == "last changed")
    .map(|e| &e.date);
lang
string
Language tag (e.g., “en”, “fr”)

Example Usage

use rdap_client::RdapClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = RdapClient::new();
    
    // Query an IP address
    let result = client.query("8.8.8.8").await?;
    
    if let Some(network) = result.ip_network() {
        println!("Network: {} - {}", 
            network.start_address.as_deref().unwrap_or("N/A"),
            network.end_address.as_deref().unwrap_or("N/A")
        );
        
        println!("Name: {}", network.name.as_deref().unwrap_or("N/A"));
        println!("Type: {}", network.network_type.as_deref().unwrap_or("N/A"));
        println!("Country: {}", network.country.as_deref().unwrap_or("N/A"));
        
        // Find abuse contact
        for entity in &network.entities {
            if entity.roles.contains(&"abuse".to_string()) {
                if let Some(vcard) = &entity.vcard {
                    if let Some(email) = vcard.email() {
                        println!("Abuse: {}", email);
                    }
                }
            }
        }
        
        // Show allocation date
        for event in &network.events {
            if event.action == "registration" {
                println!("Allocated: {}", event.date);
            }
        }
    }
    
    Ok(())
}

CIDR Query Example

// Query a CIDR block
let result = client.query("192.0.2.0/24").await?;

if let Some(network) = result.ip_network() {
    println!("CIDR block information:");
    println!("  Range: {} - {}",
        network.start_address.as_deref().unwrap_or("N/A"),
        network.end_address.as_deref().unwrap_or("N/A")
    );
    println!("  Handle: {}", network.handle.as_deref().unwrap_or("N/A"));
}

Build docs developers (and LLMs) love