josef has asked for the wisdom of the Perl Monks concerning the following question:
Hello Perlmonks,
I try to read the IP address, netmask and another parameters from the network card on the FreeBSD using IO::Interface and/or IO::Socket. On Linux the script run with no errors. My code:The result:#! /usr/bin/perl -w use IO::Socket; use Data::Dumper::Simple; use IO::Interface qw(:flags); my $s = IO::Socket::INET->new(Proto => 'udp'); @interfaces = $s->if_list; print Dumper @interfaces; for my $if (@interfaces) { next if $if =~ /usb|iwn|lo/; print "interface = $if\n"; print "addr = ",$if->addrese,"\n", "broadcast = ",$if->broadcast,"\n", "netmask = ",$if->netmask,"\n", "dstaddr = ",$if->dstaddr,"\n", "hwaddr = ",$if->hwaddr,"\n", "mtu = ",$if->mtu,"\n", "metric = ",$if->metric,"\n", "index = ",$if->index,"\n"; print "is running\n" if $if->is_running; print "is broadcast\n" if $if->is_broadcast; print "is p-to-p\n" if $if->is_pt2pt; print "is loopback\n" if $if->is_loopback; print "is promiscuous\n" if $if->is_promiscuous; print "is multicast\n" if $if->is_multicast; print "is notrailers\n" if $if->is_notrailers; print "is noarp\n" if $if->is_noarp; }
The line 25 is the line with print "addr = ",$if->addrese,"\n", ......@interfaces = ( 'iwn0', 'lo0', 're0', 'usbus0', 'usbus1', 'usbus2', 'usbus3', 'usbus4', 'usbus5', 'usbus6', 'usbus7' ); interface = re0 Can't locate object method "addrese" via package "re0" (perhaps you fo +rgot to load "re0"?) at interfaces.pl line 25.
Any idea? Or another module? On the FreeBSD the ifconfig command output is like:
Regardsre0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1 +500 options=8209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WO +L_MAGIC,LINKSTATE> ether c8:0a:a9:93:87:25 inet 172.21.100.29 netmask 0xffffff00 broadcast 172.21.100.255 inet 192.168.1.5 netmask 0xffffffff broadcast 192.168.1.5 nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL> media: Ethernet autoselect (100baseTX <full-duplex>) status: active
Josef
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Read network configuration on FreeBSD
by aitap (Curate) on Oct 10, 2012 at 17:38 UTC | |
|
Re: Read network configuration on FreeBSD
by VinsWorldcom (Prior) on Oct 10, 2012 at 17:09 UTC | |
by josef (Acolyte) on Oct 10, 2012 at 17:24 UTC | |
by josef (Acolyte) on Oct 10, 2012 at 17:41 UTC | |
by VinsWorldcom (Prior) on Oct 10, 2012 at 18:08 UTC | |
by josef (Acolyte) on Oct 10, 2012 at 18:09 UTC |