Manual switch between wan wwan (pbr)

Is there a way to manually switch between WAN and WWAN? I'm also using PBR and don't want to have to change the PBR rules.

I thought I could just rename WWAN to WAN, but that doesn't work. If my DSL connection ever goes down, I'd like to connect via WWAN and continue browsing without having to change my PBR rules to WWAN. When I switch off WAN, I always get an error message from PBR saying that my WAN interface hasn't started yet. I'm using OpenWRT 24.4.

PBR needs to know your wan (uplink) interface and if that changes you have to change that in the PBR config .

In the past there was auto detection but that failed often so was removed.

Perhaps you can make a hotplug script which changes the uplink interface in the PBR config?

    option uplink_interface 'wan'
    option uplink_interface6 'wan6'

I did a quick and dirty script. I will improve it further, perhaps with WLAN profiles. But this way I can switch between DSL and a WWAN.

#
# RouterWechsel
#

# Alle Interfaces von wan auf wwan in PBR ändern
sed -i "s/option interface 'wan'/option interface 'wwan'/g" /etc/config/pbr

ifdown wan

uci delete network.wwan
uci delete wireless.wwan_client

uci set pbr.config.uplink_interface='wwan'
uci del_list pbr.config.ignored_interface='wan'
uci add_list pbr.config.ignored_interface='wan'

uci set network.wwan=interface
uci set network.wwan.proto='dhcp' 
uci commit

# Erstellt eine neue Sektion für den WLAN-Client-Modus
uci add wireless wifi-iface
uci rename wireless.@wifi-iface[-1]=wwan_client

# Konfiguriert die Verbindung
uci set wireless.wwan_client.device='radio2'
uci set wireless.wwan_client.mode='sta'
uci set wireless.wwan_client.network='wwan'
uci set wireless.wwan_client.ssid='wlan_router_to_connect'
uci set wireless.wwan_client.encryption='psk2'
uci set wireless.wwan_client.key='password'

# Speichert die Konfiguration
uci commit
service network reload

1 Like
#
# zum normalen DSL Modus umschalten
#

# alle Interfaces von wwan auf wan in PBR ändern

sed -i "s/option interface 'wwan'/option interface 'wan'/g" /etc/config/pbr

uci delete pbr.config.uplink_interface
uci del_list pbr.config.ignored_interface='wan'

uci delete network.wwan
uci commit

ifup wan

service network reload

1 Like