How to Stop a Continuous Ping on Cambium Radio

The Cambium equipment comes with a nice little ping utility when you SSH to it. Very simple to use. Maybe we should say too simple.

usage: ping <host>
       ping -n <count> <host>
                count = 0 for continuous ping

So if I want to continuously ping a website, say incredigeek.com, I can put in the following

ping -n 0 incredigeek.com

Hit return and we are off to the races. But wait. I can’t get it to stop. Ctrl + C, doesn’t do anything, Ctrl + D or Ctrl +Z don’t help either.

Okay well fine. We’ll launch another terminal and ssh into it again and see what we can do. Excellent, now we are in aaand… wait… why are the ping results showing up here too? Help!!!

Buried in the heart of the helpful help command are these lines.

       ping -- Send ICMP ECHO_REQUEST packets to network hosts
    pingend -- End ICMP ECHO_REQUEST packets to network hosts

You don’t say. Well lets try typing in pingend with all the commotion going on in the terminal.

SSH+> pingend
Ping statistics for 142.250.191.206:
        Packets: Sent = 3, Received = 3, Lost = 0 (0% loss)

Well good to know. Saves having to reboot the device.

Simple SH Ping script to scan a /24

This is a very simple ping script I created to run on a remote UniFi device to scan for other IP addresses on it’s network. It works on SH environments as well as Bash.

Paste the script in a ping.sh file and then

chmod +x ping.sh

run like so, replacing 192.168.1. with the IP range you want to scan.

sh ping.sh 192.168.1.

#!/bin/sh
# simple ping scan utility

# i.e. 192.168.0.
ipFirstPart=$1

ip=0
while [ $ip -ne 255 ] 
do 
  ip=$(($ip+1))
  ping -w1 $ipFirstPart${ip} | grep "64 bytes from"
done

Ping multiple IP addresses to see if they are up or down

An easy way to do this is by using fping. fping is a little bit easier ping utility to use then normal ping when trying to verify that a host is actually down.

By default fping returns if a host is “alive” or “unreachable”

Example:

$ fping 192.168.1.4
192.168.1.4 is alive

Or for a host that is down it returns something like the following

$ fping 192.168.1.5
ICMP Host Unreachable from 192.168.1.2 for ICMP Echo sent to 192.168.1.5
ICMP Host Unreachable from 192.168.1.2 for ICMP Echo sent to 192.168.1.5
ICMP Host Unreachable from 192.168.1.2 for ICMP Echo sent to 192.168.1.5
ICMP Host Unreachable from 192.168.1.2 for ICMP Echo sent to 192.168.1.5
192.168.1.5 is unreachable

You can adjust the retry rate with the -r option, default is 3 which it has multiple of the Host Unreachable lines. Changing it to 1 or 2 gets rid of those lines so it just shows that the host is unreachable.

$ fping -r 1 192.168.1.5
192.168.1.5 is unreachable

Ping multiple addresses

Fortunately pinging multiple addresses with fping is as easy as adding them to the end of the command. For example

fping -r1 192.168.1.1 192.168.1.2

will ping both the specified addresses one after the other and print the results to the terminal.

Example:

$ fping -r 192.168.1.1 192.168.1.10 192.168.1.45  
192.168.1.1 is alive
192.168.1.10 is alive
192.168.1.45 is unreachable

How to Allow Ping Through Windows Firewall

Open up Windows Firewall with Advanced Security.

You can do this by going to
Control Panel –> System and security –> Windows Firewall –> Advanced settings

Or hit the Windows key and type in firewall and hit enter

Select Inbound rules and then add a New Rule.  On the New Inbound Rule Wizard select Custom for the type of rule and hit next.  Allow All programs and then hit next again.  Select ICMPv4 as the Protocol type and if you want you can specify the ICMP types by clicking on the Customize button.  Finish running through the wizard give it a name etc. and click Finish when your done.