Situation
A connection check is to be performed for a WAN chain. This is possible with on-board means in the WAN → WAN chains menu of the router. In this case, a ping to two different IP addresses is to be carried out to check the availability of at least one of the addresses. If none of the addresses can be pinged, the modem shall be reset.
Solution
This special application will be realised using a Lua script. Refer to the Lua 5.3 Reference Manual for more information about Lua.
Preparation of the Lua script
We’ve prepared the following Lua script for the described purpose. Copy and paste it to your text editor or download it using the link below. Don’t forget to change the ping IP addresses to the addresses you need to ping.
-----LUA-----
-- variable definition:
PING_ADDRESS1 = "10.10.0.1" -- replace this with your first IP address
PING_ADDRESS2 = "10.11.0.1" -- replace this with your second IP address
TRY = 3 -- this defines that an unsuccessful check will be repeated 3 times
-- aux flag
SUCCESS = 0 -- this flag is used to differentiate success (1) and no success (0)
-- ping check
for LOOP = 1 , TRY do
a, b, c = pcall(cli, "help.debug.tool=ping -c 1 " .. PING_ADDRESS1) -- lua script that pings to address 1 and returns information to the variables a, b and c
if c == 0 then -- means that the ping to address 1 was successful
SUCCESS = 1 -- sets the success flag to 1
cli_log("LUA ping - " .. LOOP .. ". check to target " .. PING_ADDRESS1 .. " successful") -- outputs the success message in the log
-- device is online, exit lua and the script
return -- exits the loop
else -- continues the script in case of no success
a, b, c = pcall(cli, "help.debug.tool=ping -c 1 " .. PING_ADDRESS2) -- lua script that pings to address 2 and returns information to the variables a, b and c
print ("LOOP: " .. LOOP .. " - b:" .. b .. " c:" ..c) -- outputs the parameter in the cli
if c == 0 then -- means that the ping to address 2 was successful
SUCCESS = 1 -- sets the success flag to 1
cli_log("LUA ping - " .. LOOP .. ". check to target " .. PING_ADDRESS2 .. " successful") -- outputs the success message in the log
-- device is online, exit lua and the script
return -- exits the loop
else -- continues the script in case of no success at the end of the final number of loops
cli_log("LUA ping - " .. LOOP .. ". check, both failed") -- outputs the no success message in the log
end
end
end
if SUCCESS == 0 then -- means that no ping was successful, the following commands will be executed
cli_log("LUA ping - restarting modem") -- outputs this information in the log
cli("help.debug.modem_state.name=lte2") -- defines the modem to be restarted
cli("help.debug.modem_state.state_change=turn_off") -- defines that the modem is to be turned off
cli("help.debug.modem_state.submit") -- submits above command to the router
end
-----LUA-----
exit
An ASCII configuration file can be used to add additional configurations to an already existing profile. We’ve prepared the following ASCII configuration file that will add a timer and an event to your profile as well as an IP filter rule that permits the ping requests. The event will execute the Lua script every time the timer expires. Copy and paste it to your text editor or download it using the link below. You may change the timer interval (and file name in case you changed it) to suit your requirements.
If a timer has already been configured in this profile, the first timer (timer1) will be overwritten by this configuration. |
events.timer.timer.add events.timer.timer[1].active=1 events.timer.timer[1].description=Timer for dual ping check with Lua events.timer.timer[1].type=interval events.timer.timer[1].interval_hh=00 events.timer.timer[1].interval_mm=10 events.event_config.event.add events.event_config.event[last].active=1 events.event_config.event[last].description=Dual ping check with Lua events.event_config.event[last].event_type=ev_timer events.event_config.event[last].event_timer_name=timer1 events.event_config.event[last].event_action_type=act_ascii events.event_config.event[last].event_action_ascii=CG_m3_lua_connection_check_script.txt netfilter.ip_filter.rule.add netfilter.ip_filter.rule[last].rule_active=1 netfilter.ip_filter.rule[last].rule_desription=Ping queries sent by the router netfilter.ip_filter.rule[last].rule_direction=output netfilter.ip_filter.rule[last].rule_protocol=icmp netfilter.ip_filter.rule[last].rule_output_if=all netfilter.ip_filter.rule[last].rule_ipversion=all administration.profiles.activate
Router configuration
It is prerequisite that you have access to the web interface of the router, an LTE modem is inserted in slot 2 and the router has been commissioned using the Startup Wizard.
The device can only be accessed via the first Ethernet socket in default settings. This avoids to bridge several networks accidentally on an already configured router when resetting to default settings. |
-
Open web interface of the router using a browser: 192.168.1.1 [1]
-
In the Administration → Profiles menu, go to the Import profile or ASCII configuration file section, click on Browse… and select the Lua script that you have downloaded above.
-
Click on Import profile.
-
In the Administration → Profiles menu, go to the Import profile or ASCII configuration file section, click on Browse… and select the ASCII configuration file that you have downloaded above.
-
Click on Import profile.
-
Click on the Apply ASCII configuration icon behind the ASCII configuration file (not the Lua script) under ASCII configurations (). [2]
-
Change to the Status → Log view menu to watch the results of this configuration in the log.
-
Check the following logs:
-
Modem
-
Network
-
CLI
-
Events
-
-
Enter a Refresh cycle of 5 seconds and click on Show entries.
Troubleshooting
-
The condition of the WAN chain and their interfaces is shown in the web interface in the Status menu on the System status page. If an interface does not achieve the online condition, its condition can also be examined in this menu.
-
If no network traffic is achieved, the tools integrated in the router can be used for debugging (TBD:LINK to debugging with integrated tools).
-
Network devices connected to the router cannot use the Internet connection. The reason can be that they have not entered the router as gateway and DNS server.
-
The IP filters can be deactivated for testing purposes. The router itself is also subject to the IP filters. If the router itself has to send packets, an OUTPUT rule is necessary for this. If the router itself has to receive packets, an INPUT rule is necessary for this. In order to be able to route IP packets, a FORWARD rule is necessary.
Back to the Configuration Guides for icom OS Smart Devices
Back to overview