scan-network.sh 865 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. # GPLv3 or later 2017 Jeff Cliff
  3. #
  4. # See COPYING.GPL
  5. #
  6. # You should have received a copy of the GNU General Public License
  7. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  8. DOES_IFCONFIG_EXIST=`which ifconfig`
  9. if [[ -z $DOES_IFCONFIG_EXIST ]]; then
  10. IPCOMMAND="ip address"
  11. else
  12. IPCOMMAND="ifconfig"
  13. fi
  14. echo "IPCOMMAND" $IPCOMMAND
  15. # sometimes ifconfig is available, this is where to find/change it if it is. maybe we should autodetect if it does
  16. network=`$IPCOMMAND | grep inet | grep -iv inet6 | grep -iv 127.0.0.1 | awk -F' ' '{print $2}' | awk -F'.' '{print $1 "." $2 "." $3 ""}' | sed -s "s/addr://g"`
  17. echo $network
  18. for y in $network; do
  19. for x in `seq 255` ;
  20. do
  21. #echo "network:" $y
  22. #echo "x:" $x
  23. #echo "network.x:" $y.$x
  24. #echo ping -c 1 $y.$x
  25. ping -c 1 $y.$x | grep -i 'ttl' | grep -iv 'Unreachable' &
  26. done
  27. echo $y ; done