Dear Team
I need to implement the following scenario.
RUTX11 with two SIMS and SIM_SWITCH to SIM2 in case SIM1 looses icmp to specific IP address.
On routers Lan we have one device#1 with IP:192.168.1.10 and device#2 with IP:192.168.1.20.
When MOB1S1A1(SIM1) is active, traffic initiated from both devices should be forwarded to their destination.
When MOB1S2A1(SIM2) is active traffic initiated only from device#1 with IP 192.168.1.10 should be forwarded and traffic from device#2 with IP 192.168.1.20 should be dropped.
I enabled sim switch when there is no connection for sim 1, it will switch to sim2
I had a custom script that will check the status of SIM2. If SIM2 is down, the traffic rule created previously is disabled. But if SIM2 is up, the traffic rule will be enabled.
#!/bin/sh
# Function to retrieve JSON result and extract mobile status
get_sim_info() {
local sim_result="$1"
mobile_status=$(echo "$sim_result" | awk -F'[:,]' '/"up"/ {print $2}')
}
# Function to check SIM connectivity
check_sim() {
local sim_name="$1"
local sim_result="$(ubus -S call network.interface."$sim_name" status)"
get_sim_info "$sim_result"
if [ "$mobile_status" = "true" ]; then
#echo "Sim2 is in use"
uci set firewall.21.enabled='1'
uci commit firewall
else
#echo "Sim1 is in use"
uci set firewall.21.enabled='0'
uci commit firewall
fi
}
# Check SIM2
check_sim "mob1s2a1_4"
The firewall number will vary on the configuration. To verify, once the firewall rule is created, run this command on CLI: uci show firewall
Then, you can configure crontab for how frequent the script will run (for example, every 30 minutes).
Hi and thanks for the help
I approached it as bellow
We enabled SIM_SWITCH for the switchover on failure, but also enable fail-over for MOB1S1A1 & MOB1S2A1 interfaces having track IP “0.0.0.0” so the interface are always online when they are active (RUTX11 has only one modem).
With fail-over enable we can take advantage of the rules that exist on fail-over page.
One rule is matching traffic from source 192.168.1.10 and can use either mobile interface (with a policy that includes MOB1S1A1 & MOB1S2A1 interfaces) and a rule that matches 192.168.1.20 and can use only MOB1S1A1 (with a policy that includes only MOB1S1A1 interface)
We have tested this very extensively and it works as expected.