Results 1 to 5 of 5

Thread: bash script: alive host?

  1. #1
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,125
    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
    7,464
    Distro
    Lubuntu Development Release

    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
    1,910
    Distro
    Kubuntu 12.10 Quantal Quetzal

    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
    7,464
    Distro
    Lubuntu Development Release

    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,125
    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
  •