<?xml version="1.0" encoding="windows-1252"?>
<node id="166951" title="Answer: List all network interfaces on the local machine?" created="2002-05-16 04:35:49" updated="2005-08-13 23:58:22">
<type id="1888">
categorized answer</type>
<author id="11732">
QandAEditors</author>
<data>
<field name="doctext">
well, if you just need IP addresses, this works on Win32 and Linux and doesn't require any external module:

&lt;code&gt;
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";
}
&lt;/code&gt;</field>
<field name="parent_node">
166645</field>
</data>
</node>
