Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Linux: Shell Script Help - Return IP Addresses

Posted on 2007-04-06
4
Medium Priority
?
1,993 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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 lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

610 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