How to disable an interface with UCI (uci set network.wwan0.enabled='0' doesn't seem to work)

How do I execute the equivalent of going through the LuCI GUI, clicking "Stop" then "Connect" under Interfaces?

I have an interface, wwan0 defined in /etc/config/network but it is not a "real" interface. What I mean by that is when it is "stopped" it is absent from the listing of ifconfig. It only shows in ifconfig when the interfaces is "connected". Normally I would do ifdown/ifup, but in my situation I am unable to do so as ifconfig does not know about the interface when it is down. I had thought that I could do this via UCI, but when I try doing uci set network.wwan.enabled='0' (use enabled for interface?) or uci set network.wwan.disabled='1' (use disabled for other objects?) followed by uci commit network, there is no effect.

Here is the interface's definition in /etc/config/network
config interface 'wwan'
option ifname 'wwan0'
option proto 'dhcp

24 am

Try with "ubus call network.interface.wwan down && ubus call network.interface.wwan up".

Thank you eduperez! That's exactly what I needed.

I'm curious -- does that actually do ifdown wwan && ifup wwan or something else?

I'm not sure, I do not know the internals of ubus... but remember that in some cases there is not a real interface to bring up / down, for example in a wireless connection, or with a VPN client.

Easily seen from the sources...

It goes the other way round: "ifup" uses ubus for the actual work.

https://git.lede-project.org/?p=source.git;a=blob;f=package/network/config/netifd/files/sbin/ifup;hb=HEAD

1 Like