Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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 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 netmask 0xffffff00 broadcast inet netmask 0xffffffff broadcast nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL> media: Ethernet autoselect (100baseTX <full-duplex>) status: active



In reply to Read network configuration on FreeBSD by josef

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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?

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

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (5)
    As of 2015-11-28 18:34 GMT
    Find Nodes?
      Voting Booth?

      What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

      Results (743 votes), past polls