Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

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:
#! /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 result:
@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.
The line 25 is the line with print "addr = ",$if->addrese,"\n", ......

Any idea? Or another module? On the FreeBSD the ifconfig command output is like:

re0: 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

Regards

Josef


In reply to Read network configuration on FreeBSD by josef

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (8)
    As of 2014-12-20 20:50 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (98 votes), past polls