Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Answer: List all network interfaces on the local machine?

by dada (Chaplain)
on May 16, 2002 at 08:35 UTC ( #166951=categorized answer: print w/replies, xml ) Need Help??

Q&A > network programming > List all network interfaces on the local machine? - Answer contributed by dada

well, if you just need IP addresses, this works on Win32 and Linux and doesn't require any external module:
my @ip = (); my($name,$aliases,$addrtype,$length,@addrs) = gethostbyname('localhost +'); # @addrs should contain the loopback - 127.0.0.1 # you can skip it if you want foreach my $addr (@addrs) { push(@ip, join('.', unpack('C4', $addr))); } ($name,$aliases,$addrtype,$length,@addrs) = gethostbyname($name); # @addrs contains our public IP address(es) foreach my $addr (@addrs) { push(@ip, join('.', unpack('C4', $addr))); } foreach my $ip (@ip) { print $ip, "\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2017-02-22 22:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (338 votes). Check out past polls.