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.
0 votes
254 views 5 comments
by anonymous
Is there a way to drop any advertised wifi networks by the RUTX11 if the egress eg 4G, vpn etc fails?

We don't want any devices to connect to the RUTX11 unless it has access to our network or the internet. So if the 4G loses its signal and our vpn drops, we would like the RUTX11 to stop advertising it's available wifi networks. Obviously, when the 4G/vpn connection necomes back online, we'd like the RUTX11 to start advertising its wifi networks again.

1 Answer

0 votes
by anonymous

Hello,

Add the following script to /etc/mwan3.user:

mobstatus = $(ubus call network.interface.mob1s1a1 status | jq .up)
wanstatus = $(ubus call network.interface.wan status | jq .up)

[ "$ACTION" == "ifdown" ] && {
	[ "$INTERFACE" == "wan" ] || [ "$INTERFACE" == "wwan0" ] && {
		[ "$mobstatus" == "false" ] && [ "$wanstatus" == "false" ] && {
			# both are down shutdown wifi
			ubus call network.interface.wlan0 down
			ubus call network.interface.wlan1 down
		}
		# at least one is up restart wifi
		ubus call network.interface.wlan0 up
		ubus call network.interface.wlan1 up
	}
}

[ "$ACTION" == "ifup" ] && {
	[ "$INTERFACE" == "wan" ] || [ "$INTERFACE" == "wwan0" ] && {
		# one is up restart wifi
		ubus call network.interface.wlan0 up
		ubus call network.interface.wlan1 up
	}
}

You may need to install jq: opkg update;opkg install jq

Regards,

Best answer
by anonymous
Wow.... any chance you can run through that code in a little more detail to explain what its doing?

We have a mob1sta1 & mob1sta2 using failover which both use the same openvpn connection so I imagine we just have to monitor the openvpn connection ie if we can't reach openvpn peer, disable the wifi (possibly after x seconds?)
by anonymous
This code is for monitoring a wan (via ethernet) and a mobile wan, if both are down disable all wireless interfaces else if at least one is up re-enable them. You can replace wanstatus by a mob2status and delete the $INTERFACE == wan for your use case.
by anonymous

So, something like this to monitor both 4G connections to stop 2 wireless interfaces:

mob1status = $(ubus call network.interface.mob1s1a1 status | jq .up)
mob2status = $(ubus call network.interface.mob1s1a2 status | jq .up)

[ "$ACTION" == "ifdown" ] && {

[ "$INTERFACE" == "mob1s1a1" ] || [ "$INTERFACE" == "mobs1a2" ] && {

[ "$mob1status" == "false" ] && [ "$mob2status" == "false" ] && {

# both are down shutdown wifi

ubus call network.interface.wlan0 down
                        ubus call network.interface.wlan1 down

}

# at least one is up restart wifi

ubus call network.interface.wlan0 up
                ubus call network.interface.wlan1 up

}

}

[ "$ACTION" == "ifup" ] && {

[ "$INTERFACE" == "mob1s1a1" ] || [ "$INTERFACE" == "mob1s1a2" ] && {

# one is up restart wifi

ubus call network.interface.wlan0 up
                ubus call network.interface.wlan1 up

}

}

by anonymous
Yes, but the second interface is mob1s2a1 not mob1s1a2.
by anonymous
My typo lol.

Many, many thanks for your assistance with this. Greatly appreciated and we'll give it a shot next week. Thank you.

Louis