Check PPP link, reset when down

We recently had an event with a DuxCel unit where one of our business units let the pre-paid data run out and it was nearly 3 weeks until it was topped up.

Because it had been left so long, even when the data was activated again, there was no cellular connection until the PPP interface was disabled/enabled.

Therefore I created the attached netwatch script (attached) – thought it may be of some use/interest to you.

Functionality is as follows:

1.     Netwatch will ping Google DNS server ( every 15 mins

2.     If there is a ping reply (within 1000ms), then “Cellular up” is logged – no further action.

3.     If there is no ping reply, Netwatch will invoke a script, the script will then:

a.     Log “Cellular down”

b.    Disable/re-enable the Cellurar4G interface (with 10s delay)

c.     Disable the Netwatch for 15 mins – to allow plenty of time for the Cellular connection to re-establish.

4.     After 15 minutes the Netwatch is enabled, and starts to ping every 15 minutes.

5.     If there is a ping reply (within 1000ms), then “Cellular up” is logged – no further action.

6.     If there is no ping reply, Step 3 repeats. 

I had to do it this was because Netwatch only functions on a change of state, so if the SIM data ran out and can’t be pinged, it would only cycle the Cellular4G interface once. It would not repeat, which is not what we need to re-establish the Cellular connectivity once the data is topped up (after a long period of time).

Download the script here!

Shared by Richard Wiltshire of RCW Consultants

Comments, suggestions, feedback is welcome!  Contact Richard!