The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Sys::Net - system network information or actions

SYNOPSIS

        my %if_named = %{Sys::Net::interfaces()};
        foreach my $if_name (keys %if_named) {
                print 'interface with name: ', $if_name, ' has ip: ', $if_named{$if_name}, "\n";
        }

        use Sys::Net 'resolv';
        my $hostname = resolv('127.0.0.1');
        my $ip       = resolv('localhost');

DESCRIPTION

The purpouse is to find out network information or perform system network actions.

System network interfaces for the moment works just for Linux, and gets only ipv4 ip of the system interfaces. Will be extended when a need arrise.

METHODS

EXPORTS

        our @EXPORT_OK = qw(resolv interfaces);

interfaces()

returns hash ref with:

        {
                'lo'   => { 'ip' => '127.0.0.1'     },
                'eth0' => { 'ip' => '192.168.100.6' },
        };

TODO more information than just an ip.

resolv()

Resolv hostname to an ip or ip to an hostname.

Using gethostbyaddr or gethostbyname so also hosts in /etc/hosts are taken into an account.

AUTHOR

Jozef Kutej