Solved

Linux: Shell Script Help - Return IP Addresses

Posted on 2007-04-06
4
1,968 Views
Last Modified: 2013-12-26
To retrieve my own IP address on the network I use the grep command. $ /sbin/ifconfig eth0| grep 'inet addr:' However, I would  like help/advice on how to write a small shell script that would find out all the ip addresses currently up and running on the network...?
0
Comment
Question by:trophyhusband
4 Comments
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 18868171

Did you try:

/sbin/ifconfig -a
0
 

Author Comment

by:trophyhusband
ID: 18868887
Thanks for your reply.

I understand from the man pages that if a single -a argument is given, it displays the status of all interfaces, even those that are down. However, when I try this I only get the my IP address returned: 10.10.0.131. The /sbin/ifconfig eth0 | grep 'inet addr:'  also gives me this same information.

If there a way where I can get an output like this?

Machines responding on Network Address:  192.168.200.0
      192.168.200.1
           192.168.200.24
      192.168.200.254
0
 
LVL 1

Accepted Solution

by:
Blue5Wing earned 125 total points
ID: 18869389
ifconfig will display information about interfaces on your box only, it does not search the network.

To get all the machines responding on 192.168.200.x you may try:
nmap -sP 192.168.200.1-254

If you can't find nmap for your specific Linux distro, get it from http://insecure.org/nmap/
0
 
LVL 48

Expert Comment

by:Tintin
ID: 18879582
Allternatively, you can ping the broadcast address, eg:

ping -s 192.168.200.255

That's assuming your netmask is a /24 (255.255.255.0)
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
while loop over for loop 7 103
ffmpeg - "rtsp://...... Operation not permitted" 4 80
changeXy challenge 13 82
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 552
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question