=item get_networkinfos This one use net::interface advantage: don't need to run external programs (/sbin/ip /sbin/ifconfig ...) disadvantage: net::interface is not so familar than /sbin/ifconfig dependancies (was already included but if the purpose was to drop this ...) TODO: ipv 6 .... =cut sub get_networkinfos { use Net::Interface qw( :inet AF_INET AF_INET6 inet_ntoa net_symbols );# actually to be sure symbols are correctly included # more easy to use inet_ntoa(..) than net::interface->inet_ntoa(...) ) my @ints; my @all_ifs = Net::Interface->interfaces(); my @ifnames = "@all_ifs"; my $family4 = 0 + AF_INET(); my $family6 = 0 + AF_INET6(); #if we want ipv6 foreach my $if (@all_ifs) { my $info = $if->info(); if (defined($info->{$family4}) ) { #family6 for ipv6 or adding a cond... my $if_name =$if->name(); next if ($if_name eq "lo"); #don't care about loopback interface .. my %ref; my $address = inet_ntoa($if->address($family4)); #address in binary form ... my $netmask = inet_ntoa($if->netmask($family4)); #netmask in binary form ... #print "device => $if_name, ip => $address, mask => $netmask \n"; #this was for debug purpose if (( $address =~/((?:\d{1,3}\.){3}\d{1,3})/) && ($netmask =~ /((?:\d{1,3}\.){3}\d{1,3})/ )) { %ref = ( 'device' => $if_name, 'ip' => $address, 'mask' => $netmask ); } push @ints, \%ref if(%ref); } } return @ints; }