SYNOPSIS
use Net::IRR;
my $host = 'whois.radb.net';
my $i = Net::IRR->connect( host => $host )
or die "can't connect to $host\n";
my $version = $i->get_irrd_version();
print "IRRd version: $version\n" unless $i->error();
print "routes by origin AS5650\n";
my @routes = $i->get_routes_by_origin("AS5650");
print "found " . scalar(@routes) . " routes\n";
print "AS-SET for AS5650\n";
if (my @ases = $i->get_as_set("AS-ELI", 1)) {
print "found " . scalar(@ases) . " AS's\n";
print "@ases\n";
}
else {
print "none found\n";
}
my $aut_num = $i->match("aut-num","as5650")
or warn("can't find object: " . $i->error . "\n");
print $i->route_search("208.186.0.0/15", Net::IRR::EXACT_MATCH)
. " originates 208.186.0.0/15\n";
print $i->get_sync_info(), "\n";
$i->disconnect();
DESCRIPTION
This module provides an object oriented perl interface to the Internet Route Registry. The interface uses the RIPE/RPSL Tool Query Language as defined in Appendix B of the IRRd User Guide. The guide can be found at http://www.irrd.net/, however an understanding of the query language is not required to use this module.Net::IRR supports IRRd's multiple-command mode. Multiple-command mode is good for intensive queries since only one TCP connection needs to be made for multiple queries. The interface also allows for additional queries that aren't supported by standard UNIX whois utitilies.
Hopefully this module will stimulate development of new Route Registry tools written in Perl. An example of Route Registry tools can be found by googling for RAToolset which is now known as the IRRToolset. The RAToolset was originally developed by ISI, http://www.isi.edu/, and is now maintained by RIPE, http://www.ripe.net/.
METHODS
- Net::IRR->connect( host => $hostname, port => $port_number )
- This class method is used to connect to a route registry server. Net::IRR->connect() is also the constructor for the Net::IRR class. The constructor returns a Net::IRR object upon connection to the IRR server or undef upon failure.
- $whois->disconnect()
- This method closes the connection to the route registry server.
- $whois->quit()
- Same as $whois->disconnect().
- $whois->get_routes_by_origin('AS5650')
- Get routes with a specified origin AS. This method takes an autonomous system number and returns the set of routes it originates. Upon success this method returns a list of routes in list context or a string of space separated routes. undef is returned upon failure.
- $whois->get_ipv6_routes_by_origin('AS5650')
- Same as $whois->get_routes_by_origin(), but returns IPv6 instead of IPv4 routes.
- $whois->get_routes_by_community($community_name)
- This method is for RIPE-181 only. It is not supported by RPSL. This method takes a community object name and returns the set of routes it originates. Upon success this method returns a list of routes in list context or a string of space separated routes. undef is returned upon failure.
- $whois->get_sync_info()
- This method provides database synchronization information. This makes it possible to view the mirror status of a database. This method optionally takes the name of a database such as RADB. If no argument is given the method will return information about all databases originating from and mirrored by the registry server. If the optional argument is given the database specified will be checked and it's status returned. This method returns undef if no database exists or if access is denied.
- $whois->get_as_set("AS-ELI", 1)
- This method takes an AS-SET object name and returns the ASNs registered for the AS-SET object. The method takes an optional second argument which enables AS-SET key expansion since an AS-SET can contain both ASNs and AS-SET keys. undef is returned upon failure.
- $whois->get_route_set("ROUTES-ELI", 1)
- This method takes an ROUTE-SET object name and returns the ROUTEs registered for the ROUTE-SET object. The method takes an optional second argument which enables ROUTE-SET key expansion since a ROUTE-SET can contain both ROUTEs and ROUTE-SET keys. undef is returned upon failure.
- $whois->match('aut-num', 'AS5650'); - get RPSL objects registered in the database
- The example above will retrieve the aut-num object with the key AS5650. This method will return the first RPSL object matching the object type and name specified as parameters to $whois->match(). undef is returned upon failure.
- $whois->get_irrd_version()
- This methods takes no arguments and returns the version of the IRRd server that was specified as the hostname to the connect() method.
- $whois->route_search("208.186.0.0/15", EXACT_MATCH)
-
The method is used to search for route objects. The method takes two arguments, a route and an optional flag. The flag can be one of four values: EXACT_MATCH, LEVEL_ONE, LESS_SPECIFIC, MORE_SPECIFIC. These constants can be imported into your namespace by using the :all or :route export tag when importing the Net::IRR module.
use Net::IRR qw( :route ); print "EXACT_MATCH = " . EXACT_MATCH . "\n";
- $whois->sources()
- This method is used to both get and set the databases used for Internet Route Registry queries. The $whois->sources() method accepts a list of databases in the order they should be searched. If no arguments are given the method will return a list of all the databases mirrored by the route registry you are connected to.
- $whois->update($database, 'ADD', $rpsl_rr_object)
- This method is used to add or delete a database object. This method takes three arguments. The first argument is the database to update. The second argument is the action which can be either ``ADD'' or ``DEL''. The third and final required argument is a route object in RPSL format.
- $whois->error()
- Most Net::IRR methods set an error message when errors occur. These errors can only be accessed by using the error() method.
AUTHOR
Todd Caine <[email protected]>COPYRIGHT
Copyright 2002-2010 by Todd Caine. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.