Net::IdentServer - An rfc 1413 Ident server which @ISA [is a] Net::Server.


use Net::IdentServer;

my $nis = new Net::IdentServer;

run $nis; # This is a working identd ...


Although you can run this as you see in the SYNOPSIS, you'll probably want to rewrite a few things.

Net::IdentServer is a child of Net::Server to be sure. If you wish to override the behaviours of this module, just inherit it and start re-writing as you go.

An example random fifteen-letter-word ident server follows:

    use strict;

    my $s = new RandomIdentServer;

    run $s;

    package RandomIdentServer;

    use strict;
    use base qw(Net::IdentServer);


    sub new {
        my $class = shift;
        my $this = $class->SUPER::new( @_ );

        open IN, "/usr/share/dict/words" or die "couldn't open dictionary: $!";
        while(<IN>) {
            if( /^(\S{15})$/ ) {
                push @{ $this->{words} }, $1;
        close IN;

        return $this;

    sub choice {
        my $this = shift;

        my $i = int rand @{ $this->{words} };

        return $this->{words}->[$i];

    sub print_response {
        my $this = shift;
        my ($local, $remote, $type, $info) = @_;

        if( $type eq "UNIX" ) {
            # intercept these valid responses and randomize them

            $info = $this->choice;

        # Do what we would have done
        $this->SUPER::print_response( $local, $remote, $type, $info );

Overridable Functions

See the DESCRIPTION for an actual example. This is the function that prints the reponse to the client. As arguments, it receives $local port, $remote port, result $os_name (in caps) and the extended $info (usually a username or error).


There exists a function that receives $local_addr, $local_port, $rem_addr, and $rem_port as arguments. Confusingly, the $local_addr and $rem_addr refer to the present socket connection, and the $local_port and $rem_port refer to the ports being queried.

You can do whatever lookups you like on this data and return a $uid. If you return a negative $uid, do_lookup will perform the standard lookup.

The default alt_lookup just returns a -1.

Lastly, if you return a string that matches m/^JP:(.+)/, then $1 will be printed as the username.


    sub alt_lookup() {
        my $this = shift;

        # You could use this _instead_ of the
        # print_response() in the DESCRIPTION section.  The
        # advantage of the print_response is that it only
        # returns a "username" when the queried connection
        # actually exists.

        return "JP: " . $this->choice;


not_found receives as arguments [see alt_lookup for description]: $local_addr, $local_port, $rem_addr, $rem_port

by default it logs a level 2 not found message and then prints the NO-USER error message

[for more info on the log() see the Net::Server docs]

The idea here is that you can do an additional lookup of the standard TCP lookup fails. For instance, you could do a lookup on a NAT'd machine in the local net.


There are only a couple choices of error messages in rfc1413

    $this->print_error($local_port, $rem_port, 'u'); # UNKNOWN-ERROR
    $this->print_error($local_port, $rem_port, 'h'); # HIDDEN-USER
    $this->print_error($local_port, $rem_port, 'n'); # NO-USER
    $this->print_error($local_port, $rem_port, 'i'); # INVALID-PORT

You could, of course, write your own by overriding this function entirely. But otherwise picking something besides the four examples shown will earn you an error and an exit(1).


The entire ini file is stored in your server object. Each section is it's own hash key and each value is a key of the section.

Example: $this->{conf}{server}{port}

This is the port listed under the server section of your ini file.


Jettero Heller <>

Jet is using this software in his own projects... If you find bugs, please please please let him know. :) Actually, let him know if you find it handy at all. Half the fun of releasing this stuff is knowing that people use it.

Additionally, he is aware that the documentation sucks. Should you email him for help, he will most likely try to give it.


GPL! I included a gpl.txt for your reading enjoyment.

Though, additionally, I will say that I'll be tickled if you were to include this package in any commercial endeavor. Also, any thoughts to the effect that using this module will somehow make your commercial package GPL should be washed away.

I hereby release you from any such silly conditions.

This package and any modifications you make to it must remain GPL. Any programs you (or your company) write shall remain yours (and under whatever copyright you choose) even if you use this package's intended and/or exported interfaces in them.


Holy smokes, Net::Server is the shizzo fo shizzo. Everyone send a blessing to this guy, seriously.

Paul T. Seamons <paul at>


perl(1), Net::Server