I am trying to find a list of IPs in a linux window. Currently, my installation is a CentOS machine with several additional interfaces for eth0 for each VLAN. I am writing a script to find out if each VLAN IP address has a connection to specific IP addresses (different IP addresses for each network).
For instance:
eth0 has an IP address of 10.0.0.2 netmask 255.255.255.128
eth0.2 has an IP address of 10.0.130 netmask 255.255.255.128
eth0.3 has an IP address of 10.0.1.2 netmask 255.255.255.128
Each interface is currently configured for a static IP address through configuration files. However, I want 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:
@devarray = `cat /etc/sysconfig/network-scripts/ifcfg-eth0* | grep IPADDR=10 -B 10 | grep -v "#" | grep IPADDR`;
Is there a better way to determine which IP addresses are available. All I need to collect is just the IP address, not the device name.
source
share