I am looking for a linux command that can be used to find the IP addresses of the different systems connected in the same network. All the systems are running Fedora 14.

Thanks in Advance..

  • This is not a programming question. – unwind Dec 14 '12 at 10:56
  • and indeed, would belong in SuperUser. – CustomX Dec 14 '12 at 11:15
  • Check if rup or ruptime show something. – ott-- Dec 14 '12 at 15:02

I don't think there's a fully general way to do this. However, there are a couple of things you could try.

One is to run arp -a. This will print the current state of the ARP cache, which contains the IP addresses and MAC addresses of every local machine that your machine has communicated with recently. This is the information you need, but only for a subset of the hosts on the network.

Another is to use multicast. Are your machines running Avahi? If so, you can make mDNS queries on them; try running avahi-browse -at.

I originally thought that a side-effect of this would be that your machine communicates with the machines advertising mDNS resources, which would bring their details into the ARP cache, which you could then list as above. However, this seems not to be the case.

However, what you can do is ask for a resolution of the advertised services, which obtains the machines' IP addresses. You can then extract these from avahi-browse's output. Like so:

avahi-browse -atr | egrep -o '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | sort -u

This will only find machines advertising services via mDNS, but there's a good chance that this is all your machines; modern Linux systems advertise a Workstation service, for some reason.

| improve this answer | |

nmap is definitely the command you're looking for. You can do:

nmap -sn

to scan everything on a network. To do a more in depth scan of a specific machine, you could try:

nmap -A -T4

for example. Note: you'll need 'sudo' or root to enable some of the scan functions, but not for a basic ping.

| improve this answer | |

I wouldn't know of such a command, but you could use a piece of software. Angry IP scanner is the one I use in Windows and I found a Linux version too.

| improve this answer | |
  • A more linux-ey program would be nmap, which is very commonly used for things like this. Try issuing "sudo nmap -sP xxx.xxx.xxx.xxx/24" , where the x's are your computer's IP address. – Arkenklo Dec 15 '12 at 22:24
  • ooh thanks! :) not that avid Linux user, but will definately try this in the future – CustomX Dec 17 '12 at 7:39

Combine nmap and arp for best results especially if there is iptables involved :

(this is for android, so change few things)

echo "running LIST scan..." 
su -c "/data/data/jackpal.androidterm/nmap/nmap -sL >/dev/null 2>&1" 
echo "running PING scan..." 
su -c "/data/data/jackpal.androidterm/nmap/nmap -sP >/dev/null 2>&1"
echo "------------------------------"
arp|grep ether|awk '{print $2,$4}'

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy