How can i make the router work on WAN and if it won't switch to 4G

I want to ask you, how can I make the router work only on WAN and if the network stops, switch to 4G for backup. I want to add that the router is connected via VPN to another router.

I have added the following code in startup

while true; do
    if ! ping -c1 -w5 >/dev/null; then
        /sbin/ifup wwan
        sleep 10
    sleep 5

use the mwan3 package

1 Like

I think I managed to drive it. Thank you very much :slight_smile:

Interface status:
interface wan is online 00h:04m:02s, uptime 00h:15m:07s and tracking is active
interface wanb is online 00h:05m:12s, uptime 00h:10m:44s and tracking is active

Current ipv4 policies:
wanb (50%)
wan (50%)

According to your first post, you want failover between wan and wwan, which means, wan XOR wwan. You have to adjust mwan3 config for this.

@vgaetera can netifd alone effect this?

I want when there is a WAN, only it works, and when it disappears, it switches to WWAN (WANB)

"You have to adjust mwan3 config for this."
can any direction how exactly to do it?

The linked section effectively implements a custom WAN metric with PBR.
netifd by itself can neither perform connectivity check nor automatically change interface status.

You can omit the config opts for IPv6, if no IPv6 used.

Do you know how I can make it connect to the VPN through wwan?
when I do a test, the router connects via WAN and when i stop it the connection is lost

Sorry, I do not understand. In a correct setup, wireguards connection, at least, also fails over.