title: How can I find the IP addresses for each interface, in Perl?
body: <p>I am trying to find a list of IP addresses on a linux box.  Currently my setup is a CentOS machine with a few sub interfaces for eth0 for each VLAN.  I am writing a script to see if each VLAN IP address has connectivity to certain IP addresses (different IP addresses for each network).</p>
  
  <p>For example:</p>
  
  <ul>
  <li><p>eth0 has an IP of 10.0.0.2 netmask 255.255.255.128</p></li>
  <li><p>eth0.2 has an IP of 10.0.130 netmask 255.255.255.128</p></li>
  <li><p>eth0.3 has an IP of 10.0.1.2 netmask 255.255.255.128</p></li>
  </ul>
  
  <p>Each interface is currently set to static IP address via config files.  However, I am wanting to change it from static to DHCP and get the same IP address.  If I do this, it will break this part of the script:</p>
  
  <pre><code>@devarray = `cat /etc/sysconfig/network-scripts/ifcfg-eth0* | grep IPADDR=10 -B 10 | grep -v "#" | grep IPADDR`;
  </code></pre>
  
  <p>Is there a better way of determining what IP addresses are avaiable.  All I need to gather is just the IP address and not the device name.</p>