FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
+1 vote
798 views 6 comments
by anonymous

Hi,

We use the failover between mobile and WAN (satellite) interfaces and to force one interface, we change the interface priorities with these commands in order to mimic programmatically the changes done by the web interface manually:

ubus call uci set '{"config": "network", "section": "wan", "type":"interface", "values": {"metric": "0"}}'
ubus call uci set '{"config": "network", "section": "mob1s1a1", "type":"interface", "values": {"metric": "1"}}'
ubus call uci set '{"config": "network", "section": "mob1s2a1", "type":"interface", "values": {"metric": "2"}}'
ubus call uci set '{"config": "mwan3", "section": "wan_member_mwan", "type":"member", "values": {"metric": "0"}}'
ubus call uci set '{"config": "mwan3", "section": "mob1s1a1_member_mwan", "type":"member", "values": {"metric": "1"}}'
ubus call uci set '{"config": "mwan3", "section": "mob1s2a1_member_mwan", "type":"member", "values": {"metric": "2"}}'
ubus call uci commit '{"config": "network"}'
ubus call uci commit '{"config": "mwan3"}'


Actually, these commands are sent through the JSON-RPC interface from another PC on LAN.

But from time to time (after some minutes and a couples of switches) the mwan3 program stop working. In facts it is stuck on a lock:

root@Teltonika-RUTX09:~# ps | grep mwan3 
12486 root      1260 S    /bin/sh /etc/rc.common /etc/init.d/mwan3 reload
12525 root      1384 S    /bin/sh /usr/sbin/mwan3 restart
13248 root      1136 S    lock /var/run/mwan3.lock
13254 root      1136 S    lock /var/run/mwan3.lock
13258 root      1136 S    lock /var/run/mwan3.lock
17477 root      1136 R    grep mwan3

And the parent ID of the process owning the lock is 1 (init) so the process is an orphan and unlock is never called:

root@Teltonika-RUTX09:~# grep PPid: /proc/`cat /var/run/mwan3.lock`/status | grep -o "[0-9]*"
1

And killing this process allows mwan3 to restart and work again.

This issue is quite annoying on an unmanned vehicle.

Is there an issue with the commands in our script? Is there a better way to force one interface or another while using the failover?

Thank you

1 Answer

0 votes
by anonymous

Hello, 

For the issue you are having I believe you just want to configure a simple WAN failover between the WAN interfaces. I would like to get the full information on how you intend to implement the failover feature what is the priority could you give me these details so that I can generate the solution from my side. 

I just want to know you want to do failover for SIM1 to SIM2 when SIM is not available you want to proceed with the Wired WAN connectivity? Is this correct? If yes, you only need to enable this via uci set: 

uci set mwan3.mob2s1a1.enabled='1'
uci set mwan3.mob2s1a1_member_mwan.metric='1'

uci set mwan3.wan.enabled='1'
uci set mwan3.wan_member_mwan.metric='2'

uci set mwan3.mob1s1a1.enabled='1'
uci set mwan3.mob1s1a1_member_mwan.metric='0'


uci set network.wan.metric='2'
uci set network.mob2s1a1.metric='1'
uci set network.mob1s1a1.metric='0'

uci commit mwan3 
uci commit network

/etc/init.d/network restart
/etc/init.d/mwan3 restart


I hope it helps.

Regards,
Mellow

by anonymous

Hello Mellow,

Thank you for your answer.

My use case is an unmanned vehicle on which orders are given through a web interface exposed on VPN served by an OpenVPN Access Server. The primary WAN can be a 4G mobile link and a failover to a satellite based connection available on the WAN Ethernet port. But on location with bad mobile coverage, I prefer to manually (through my custom interface) switch to WAN (satellite) as primary interface and if the WAN link is lost, I want an automatic failover to the mobile interface.

So your approach is want I ended-up trying. But after very few switches, the mwan3 process is stuck by a lock issue as mentioned in my original post.

This morning, I have done a factory reset on a RUTX09 with latest firmware 2.06.1 and then enable failover through the web interface :

On SSH session, I have started the following script, based on your answer, to test several 

#!/bin/sh

count=1
while true ; do
    echo "Loop $count"

    echo "Set Mobile as primary"
    uci set mwan3.mob1s2a1.enabled='1'
    uci set mwan3.mob1s2a1_member_mwan.metric='1'

    uci set mwan3.wan.enabled='1'
    uci set mwan3.wan_member_mwan.metric='2'

    uci set mwan3.mob1s1a1.enabled='1'
    uci set mwan3.mob1s1a1_member_mwan.metric='0'

    uci set network.wan.metric='2'
    uci set network.mob1s2a1.metric='1'
    uci set network.mob1s1a1.metric='0'

    uci commit mwan3
    uci commit network

    /etc/init.d/network restart
    /etc/init.d/mwan3 restart

    sleep 60

    echo "Set WAN as primary"
    uci set mwan3.mob1s2a1.enabled='1'
    uci set mwan3.mob1s1a1_member_mwan.metric='2'

    uci set mwan3.wan.enabled='1'
    uci set mwan3.wan_member_mwan.metric='0'

    uci set mwan3.mob1s1a1.enabled='1'
    uci set mwan3.mob1s1a1_member_mwan.metric='1'

    uci set network.wan.metric='0'
    uci set network.mob1s2a1.metric='2'
    uci set network.mob1s1a1.metric='1'

    uci commit mwan3
    uci commit network

    /etc/init.d/network restart
    /etc/init.d/mwan3 restart

    sleep 60

    count=$((count + 1))
done
by anonymous

But the script is stuck. And the lock issue happen :

root@Teltonika-RUTX09:~# ps | grep mwan3
10733 root      1260 S    /bin/sh /etc/rc.common /etc/init.d/mwan3 restart
11381 root      1384 S    /bin/sh /usr/sbin/mwan3 start
11400 root      1136 S    lock /var/run/mwan3.lock
11406 root      1136 S    lock /var/run/mwan3.lock
11413 root      1136 S    lock /var/run/mwan3.lock
11430 root      1136 S    lock /var/run/mwan3.lock
13475 root      1136 S    grep mwan3
root@Teltonika-RUTX09:~# cat /var/run/mwan3.lock
11400
root@Teltonika-RUTX09:~# ps | grep mwan3
14454 root      1348 S    /bin/sh /usr/sbin/mwan3rtmon
15713 root      1252 S    /bin/sh /usr/sbin/mwan3track wan eth1 online 10.0.5.10 cfg05fbac
16555 root      1244 S    /bin/sh /usr/sbin/mwan3track mob1s1a1 qmimux0 online 10.17.111.206 cfg0bfbac
17053 root      1136 R    grep mwan3

Can you please test this script to confirm the issue?

Thank you

by anonymous

Hello, 

At first, you want to set your Failover from Mob1s2a1 as the primary network connection so when the vehicle Mobile connectivity is not available it will automatically switch to Wired WAN(Satellite). Where it will be vice versa when the Mobile network is available it will automatically switch to Mobile WAN. 

The said script mentioned below is the configuration of Failover: 

  echo "Set Mobile as primary"
    uci set mwan3.mob1s2a1.enabled='1'
    uci set mwan3.mob1s2a1_member_mwan.metric='1'

    uci set mwan3.wan.enabled='1'
    uci set mwan3.wan_member_mwan.metric='2'

    uci set mwan3.mob1s1a1.enabled='1'
    uci set mwan3.mob1s1a1_member_mwan.metric='0'

    uci set network.wan.metric='2'
    uci set network.mob1s2a1.metric='1'
    uci set network.mob1s2a1.metric='0'

    uci commit mwan3
    uci commit network

    /etc/init.d/network restart
    /etc/init.d/mwan3 restart
Now if you want to force the failover to stay on Mobile or Wired WAN. 

you can try disabling the failover itself let say:

WAN Connectivity

uci set mwan3.mob2s1a1.enabled='0'
uci set mwan3.wan.enabled='1'
uci set mwan3.mob1s1a1.enabled='0'
uci commit mwan3 
/etc/init.d/mwan3 restart

Sim 2 Connectivity
 
uci set mwan3.mob2s1a1.enabled='1'
uci set mwan3.wan.enabled='0'
uci set mwan3.mob1s1a1.enabled='0'
uci commit mwan3 
/etc/init.d/mwan3 restart

Let me know the results. 

Regards,
Mellow

 
by anonymous
Thank you for your fast reply.

But when I force WAN, I still want to have the failover to Mobile enabled because the satellite connection is not stable enough and if I lose the satellite link, I will lose the control to the vehicle.
by anonymous
Hello,

Could you send me a copy of the troubleshoot file of the said router via PM. So that I can share this one also with our RnD team to give them more details on what is happening.

Regards,
Mellow
by anonymous
Hello Mellow,

I have sent you the requested file in private message.