Solved

Linux: Shell Script Help - Return IP Addresses

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
format the code in java 6 86
modThree challenge 4 79
zeroMAx challenge 20 87
Detect file exist or not 3 132
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

910 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

23 Experts available now in Live!

Get 1:1 Help Now