Question Locked

Ping a range from IOS

0 helpful
16 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,
Is there a way to scan a range if IP addresses, like a whole subnet, from within Cisco router IOS?
I want to scan which hosts are alive on a subnet that I only have a Cisco router on it, and don't want the System Admin to do it for me everytime.

16 replies

by tobif

Can't you just read the ARP cache?

by i2_k5

"show arp" command lists only live hosts within the arp TTL time. If u hav a live host that had no communication for a while, will not be displayed..

by tobif

What about show mac-address-table

by netman1958

For a subnet, let's say 172.16.1.0/24 try:
"ping 172.16.1.255"

by i2_k5

Thanks for the reply,
In fact this displays a result similar to what a unix server displays..
I dont know why not all hosts reply to this command. One server replies when I ping its IP, but does not reply when I ping the broadcast address!! That is exactly what is happening with our UNIX system admin.
Any idea?

by netman1958

Does your Cisco device support TCL? You can find out by entering "tclsh" from priviledged exec mode. If it responds with:
Cisco-831(tcl)#
then it supports it. If so you can do something like this:

Cisco-831(tcl)#for {set n 1} {$n<=5} {incr n} {
+>puts [exec "ping 172.16.1.$n"]
+>}

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.2, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.4, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.5, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)

Cisco-831(tcl)#

by i2_k5

First, mac-address-table also have a time to live, after that time the entry will be removed from the list
Second, Unfortunately not all cisco routers IOSs support this command (even some new IOSs do not)
Thanks

by tobif

In your initial question, you kind of wanted to ping machines, so I figured you're only after what machines are currently on the network.

I'd suggest you try to ping the ip subnet you're after from your own computer, then go and read the MAC or ARP table (your choice depending on TTL etc.) There would be a chance that your activity will update the entries.
Maybe there's some smart command to ask all hosts on a physical network to chime in, to update some routing tables. But, since I don't have any Cisco routers to play with, I can't help you much more in that direction.

Oh, do you, by chance, have access to any DHCP database?
Hm. Talking about DHCP, if you can shorten the lease time on DHCP to be less than the routing cache time, then you should always have fresh data for DHCP clients available on the routing caches :)

by i2_k5

Telnetting two hops to reach the mentioned Cisco router, so my pc in a different subnet, routing is disabled (on purpose)between my pc subnet and target subnet, so I cant run any Ip scanners from my pc.
DHCP is not an option in my case.
Asking the SysAdmin to do an IP scan on a machine within that subnet is valid, I used to ask him, but I thought there may be a way I can do myself.
There is another reply to this question, pinging the broadcast address.. but not accurate..
:)

by i2_k5

It is a ncie brainstorming session(s)..
I enjoyed it, even though it seems "pinging a range on Cisco router" is not available yet...

by tobif

Is it possible to ping (or quickly send one small udp packet from the intermediate host you telnet to? (i.e. do you have any useful rights on the first telnet destination?)

EditAdd: Worst case - you could have a script that would try to initiate telnet-sessions from your "second hop", as a way to refresh ARP data. (But then you'd probably need to set a longer TTL for ARP...)

by cg it

they just aren't the built in utilities. you can get a trial version and try that... I think solar winds has one.

by i2_k5

Unforetuneately,
TCL is not supported on this spesific model, but I will keep this solution for future tests on other models..
Thanks

by tobif

i2_k5 sent me a private message:
"Hi, I tried to reply but it gives me "You have reached your maximum message level" message !!?"

When you've reached the max nesting level, the trick is to reply on the message one level above.

by i2_k5

:) It is a ncie brainstorming session(s)..
I enjoyed it, even though it seems "pinging a range on Cisco router" is not available yet...

This discussion is closed to new replies.