-1

mtr

As picture showed above, since mtr can only traceroute one host once, how can I "scan" the whole network (172.16.0.0/16) and find all the hosts which only got 2 hops, with a script? Thank you.

2 Answers2

1
#!/bin/bash
  
touch result

for ip in 172.16.{35..254}.{1..254}
do
        echo "Trying $ip ... "
        hops=$( mtr -c 5 -r -n4 -T $ip | wc -l )
        if [[ "$hops" == 4 ]]; then
                echo "Yes!"
                echo $ip >> result
        fi
done
Brandon
  • 61
  • 1
  • 7
-2

For those who may need it, the simple way: enter image description here

  • 2
    Maybe you should copy/paste text instead of showing scripts as an image -> downvoting. – Marki Mar 11 '19 at 16:46