Solved

Linux: Shell Script Help - Return IP Addresses

Posted on 2007-04-06
4
1,961 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 126
java ^ examples 8 57
FizzBuzz challenge 9 73
sumHeights  challenge 17 60
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now