Solved

Linux: Shell Script Help - Return IP Addresses

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Ubuntu 16.04 Emergency Boot 2 234
sumNumber challenge 16 140
Linux Hanging with disable Error Output 4 95
How do I get Window Title of all opened process? 4 39
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 …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.

730 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