Announcement

Collapse
No announcement yet.

How do I find the list of all hostnames on a network?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I find the list of all hostnames on a network?

    It's a network of a bunch of different computers which are all running linux and which share a filesystem (in other words, my home/mmcevoy folder is identical on all computers in the network). I'm sshed into one of the old hosts. I know they added new computers to the network, but I don't know what they called them. I checked the /etc/hosts file, but it only lists the hostname for the one I'm actually logged into.

    Is there any file which will contain a list of all hostnames on the network, or is there any command which will bring up a list of the available hosts?
    12-17-10 Mohamed Bouazizi NEVER FORGET
    Stadtluft Macht Frei
    Killing it is the new killing it
    Ultima Ratio Regum

  • #2
    A cheapass way that I could think of is... find out the broadcast address for the network (/sbin/ifconfig helps, it probably ends with 255), ping that, and ask for the name of every host that responds. This line worked on the system where I tested it:

    ping -b -c 2 130.231.243.255 | grep "bytes from" | cut -d " " -f 4-| cut -d : -f 1|xargs -n 1 host
    This is Shireroth, and Giant Squid will brutally murder me if I ever remove this link from my signature | In the end it won't be love that saves us, it will be mathematics | So many people have this concept of God the Avenger. I see God as the ultimate sense of humor -- SlowwHand

    Comment


    • #3
      I think you normally specifically design DNS servers so that you can't get a list of hostnames on a network. So you have to do a broadcast ping on the network and see who answers.

      You can of course also see the local DNS server configuration, if the machines have subdomain names.

      You can get the list of computers to which you have a connection by running

      netstat -t

      If you run that on the computer from which the directory is mounted then you should get a list.
      http://www.hardware-wiki.com - A wiki about computers, with focus on Linux support.

      Comment

      Working...
      X