08-10-2006 11:36 PM - edited 03-03-2019 04:28 AM
I want to PINg a range of ip addresses, C-class from my router.
Is there a command that supports this or not ?
08-10-2006 11:47 PM
Hi,
If you want to ping all the devices within a particular subnet say a.b.c.0 then ping the address a.b.c.255 from the router. You'll get a response from all the devices which are alive.
Hope this helps.
Regards,
AbhisheK
Please rate all posts!!!
08-10-2006 11:57 PM
Thanks,
I was using a.b.c.0 but that didn't work.
08-11-2006 12:02 AM
You are welcome!
Please rate the post if it helped you...
08-11-2006 12:19 AM
I suggest to use those scan tool to check the IP availability. Or write a script and ping from a host.
08-11-2006 01:12 AM
Hello,
in addition to the other posts, check if your router supports tcl scripting (I think it starts with IOS 12.3). Here is an example of such a script (this one would ping addresses 192.168.1.1 thru 192.168.1.10):
Router#
Router#tclsh
Router(tcl)#foreach i {
+>192.168.1.1
+>192.168.2.1
+>192.168.3.1
+>192.168.4.1
+>192.168.5.1
+>192.168.6.1
+>192.168.7.1
+>192.168.8.1
+>192.168.9.1
+>192.168.10.1
+>} {ping $i}
When you are done, exit tcl with this command:
Router(tcl)#tclquit
HTH,
GNT
08-11-2006 02:32 AM
One clarification to the suggestion about pinging to the subnet broadcast address. This will work if the router interface where the hosts are located is configured with ip directed-broadcast. It will not work if the router interface is configured with no ip directed-broadcast. In earlier versions of IOS the default was ip directed-broadcast. But for a good while the default has become no ip directed-broadcast. So for many routers you may have to turn on this feature for the ping to the subnet broadcast address to work.
The reason that Cisco changed the default for this feature was concern from a security perspective. The ability to remotely send a broadcast to every device in the subnet is involved in several Denial Of Service attacks. I would suggest that you think carefully before you enable directed broadcast.
HTH
Rick
08-11-2006 03:15 AM
Hey!
Rick,
Thanks for adding that bit of info, I missed out on that one!
Regards,
AbhisheK
08-11-2006 03:27 AM
AbhisheK
You are welcome.
When I read the original post my first reaction was that the closest that we could come on the router was to ping the broadcast address of the subnet. So we both had the same idea of a solution. I just added the clarification that directed broadcast must be enabled for this to work. And that directed broadcast does have some security implications.
It is good that the forum is a collaborative process.
HTH
Rick
04-08-2020 09:13 PM
show about this
#ping 192.168.100.255 (the broadcast address)
06-24-2020 11:33 PM
pjpporf000#ping 10.144.64.246 10.255.255.255
^
% Invalid input detected at '^' marker.
I get his error ???....
06-27-2020 10:15 AM
The syntax for ping on an IOS router does not provide for a second IP address in the command. So what you are getting is the expected behavior.
09-08-2021 07:36 AM
BTW, I recall (??? [NB: I no longer have access to any actual Cisco devices]) extended ping (i.e. prompted version - although some IOS support more options on the command line too) supports a range of IPs.
09-08-2021 04:36 AM - edited 09-08-2021 04:58 AM
There is already a good solution in the post above. Which is very much appreciated but there is a limitation.
Person wanting to run the script need to write/generate the list(rows) containing all the ip addresses which needs to be pinged.
For example if there was a need to ping ip ranging from 192.168.0.1 to 192.168.0.16
Either all the ip addresses need to be typed manually or generated using some automated method.
192.168.0.1
192.168.0.2
192.168.0.3
.
.
.
.
192.168.0.16
Moreover, If a template file is created for future use and next time the need arises to ping ip in different subnet e.g 10.10.0.1 to 10.10.0.32
Then either the ip list need to be typed manually, automated or find and replace feature need to be used.
A quick solution with minimal input every time ping is required would be to use cisco IOS terminal shell feature. Examples are shown below from different switches
Script syntax:
enable
terminal shell
terminal shell trace
n=0
while true; do
let n++
if [[ $n -le 5 ]]; then
#echo $n
ping ip 10.12.32.$n timeout 1 repeat 1
else
break;
fi
done
Example 1:
SWITCH-1#sh ver | i Model Number
Model Number : C9300-48P
SWITCH-1#
SWITCH-1#
SWITCH-1#
SWITCH-1#sh ver | i C9300-48P
cisco C9300-48P (X86) processor with 1343576K/6147K bytes of memory.
Model Number : C9300-48P
* 1 65 C9300-48P 16.12.4 CAT9K_IOSXE INSTALL
SWITCH-1#enable
SWITCH-1#terminal shell
SWITCH-1#terminal shell trace
SWITCH-1#
SWITCH-1#
SWITCH-1#n=0
SWITCH-1#while true; do
do..done>let n++
do..done>if [[ $n -le 5 ]];
then.else.fi> then
then.else.fi>ping ip 10.12.32.$n timeout 1 repeat 1
then.else.fi>else
else..fi>break;
else..fi>
else..fi>fi
do..done>done
Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 10.12.32.1, timeout is 1 seconds:
!
Success rate is 100 percent (1/1), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 10.12.32.2, timeout is 1 seconds:
!
Success rate is 100 percent (1/1), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 10.12.32.3, timeout is 1 seconds:
!
Success rate is 100 percent (1/1), round-trip min/avg/max = 9/9/9 ms
Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 10.12.32.4, timeout is 1 seconds:
.
Success rate is 0 percent (0/1)
Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 10.12.32.5, timeout is 1 seconds:
.
Success rate is 0 percent (0/1)
Above shows few successful and unsuccessful pings.
Example 2:
TEST-SWITCH#sh ver | i Model number
Model number : WS-C2960-24PC-L
TEST-SWITCH#sh ver | i WS-C2960-24PC-L
cisco WS-C2960-24PC-L (PowerPC405) processor (revision C0) with 65536K bytes of memory.
Model number : WS-C2960-24PC-L
* 1 26 WS-C2960-24PC-L 15.0(2)SE8 C2960-LANBASEK9-M
TEST-SWITCH#enable
TEST-SWITCH#terminal shell
TEST-SWITCH#terminal shell trace
TEST-SWITCH#n=0
TEST-SWITCH#while true; do
do..done>let n++
do..done>if [[ $n -le 5 ]];
then.else.fi> then
then.else.fi>ping ip 10.12.32.$n timeout 1 repeat 1
then.else.fi>else
else..fi>break;
else..fi>
else..fi>fi
do..done>done
Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 10.12.32.1, timeout is 1 seconds:
!
Success rate is 100 percent (1/1), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 10.12.32.2, timeout is 1 seconds:
!
Success rate is 100 percent (1/1), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 10.12.32.3, timeout is 1 seconds:
!
Success rate is 100 percent (1/1), round-trip min/avg/max = 9/9/9 ms
Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 10.12.32.4, timeout is 1 seconds:
.
Success rate is 0 percent (0/1)
Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 10.12.32.5, timeout is 1 seconds:
.
Success rate is 0 percent (0/1)
TEST-SWITCH#
Above shows few successful and unsuccessful pings.
Basic command/script explanation:
# Enter enable mode
enable
#Set shell environment for current terminal
terminal shell
#Turn on trace for current shell terminal
terminal shell trace
# below the variable n is initialized with value 0
n=0
# While loop begins
while true; do
# variable counter incrementing for every iteration
let n++
# if condition checks the value of variable is less than and equal to 5. You can change 5 to another number (last octet in ipv4)
if [[ $n -le 5 ]]; then
# doing ping to one ip in one iteration and pinging next ip in next iteration. starting from 10.12.32.1 then 10.12.32.2, 10.12.32.3, 10.12.32.4 and finally 10.12.32.5. ping Timeout is 1 sec and repeat count is set to 1.
ping ip 10.12.32.$n timeout 1 repeat 1
# else condition
else
break;
fi
done
Note:
In order to disable the Shell CLI, enter:
Switch#terminal no shell
Above will disable shell for current terminal session
Whereas to set shell permanently, user the command
shell processing full
and save the config.
Example:
TEST-SWITCH#conf t
Enter configuration commands, one per line. End with CNTL/Z.
TEST-SWITCH(config)#shel
TEST-SWITCH(config)#shell ?
init Initialisation options
map Map event trigger to function
processing Enable shell processing
trigger Set shell trigger configuration
TEST-SWITCH(config)#shell pro
TEST-SWITCH(config)#shell processing ?
full Enable shell processing in all IOS modes
<cr>
TEST-SWITCH(config)#shell processing f
TEST-SWITCH(config)#shell processing full
TEST-SWITCH(config)# do write
Building configuration...
[OK]
09-13-2023 12:35 PM
Is there a break command? I entered 254 to ping the whole subnet and wanted to stop after a bit but ctl+shift+6 didn't break the loop. Any suggestions?
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide