Results 1 to 5 of 5

Thread: bash script: alive host?

  1. #1
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,126
    Distro
    Ubuntu 10.04 Lucid Lynx

    Question bash script: alive host?

    Hi everyone,
    Im looking for a function, or program I can call via a script that will allow me to get the hostname, and IP of only alive hosts. When by alive, I mean hosts that are on the network and responding to ping type requests. When I poll the Domain name server, I get names and addresses which may not be currently active.
    Does anyone have a good idea for this?
    ~Conradin~

  2. #2
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: bash script: alive host?

    Please give an example of what kind of input you want to provide and what kind of output you expect.

  3. #3
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,172
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: bash script: alive host?

    Quote Originally Posted by conradin View Post
    Hi everyone,
    Im looking for a function, or program I can call via a script that will allow me to get the hostname, and IP of only alive hosts. When by alive, I mean hosts that are on the network and responding to ping type requests. When I poll the Domain name server, I get names and addresses which may not be currently active.
    Does anyone have a good idea for this?
    In theory this should be enough:
    - "ifconfig <interface>" e.g. "ifconfig eth0" of "ifconfig wlan0"
    - Retrieve the broadcast address (Bcast:")
    - "ping -b {broadcast_address} and check who answers

    In practice due to firewalls plenty of hosts won't answer.

  4. #4
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    nmap

    Quote Originally Posted by ofnuts View Post
    In theory this should be enough:
    - "ifconfig <interface>" e.g. "ifconfig eth0" of "ifconfig wlan0"
    - Retrieve the broadcast address (Bcast:")
    - "ping -b {broadcast_address} and check who answers
    That looks interesting but for me it only returns the ping of a single host instead of what should be available on the subnet.

    What about nmap?

    Code:
    sudo nmap -sP 192.168.100.1-255

  5. #5
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,126
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: bash script: alive host?

    Thanks Lars,
    nmap actualy works quiet well for what Im trying to do, I'll use that.
    ~Conradin~

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •