Discover and Parse Active IP Addresses
Is there a way to easily discover active hosts on a subnet and parse their IPs into a file? I'm thinking about a bash script which follows the following psuedo code:
Code:
Obtain system IP through ifconfig and parsing out the IP using sed Thanks! |
Have you considered using nmap?
|
Large problems are made easier by breaking them into smaller problems.
Quote:
Quote:
Also, there are many ways to use regular expressions to match an IP address (some are more precise than others). I'd start by searching the forums and google. |
Well, nmap is part of it, but it returns something like this:
Code:
[root@redshirt ~]# nmap -sP 192.168.1.0/24 |
The regex guide I've been working out of is at http://regular-expressions.info and they have an example for matching IPs, listed as
Code:
\b(?:\d{1,3}\.){3}\d{1,3}\b |
Quote:
|
Code:
# nmap -sP 192.168.1.0/24 | grep '\b(?:\d{1,3}\.){3}\d{1,3}\b' |
Grep doesn't understand PCREs. Use perl if you want those:
Code:
perl -ne 'print "$1\n" if /(\b(?:\d{1,3}\.){3}\d{1,3})\b/' Code:
grep -oE '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}' |
Quote:
|
All times are GMT -5. The time now is 08:00 PM. |