Cannot set network with uci command

Hello everyone,
I'm having trouble when using uci commands to config networks on OpenWrt.

uci set network.lan.ipaddr='192.168.19.191'
uci set network.lan.gateway='192.168.19.1'
uci set network.lan.netmask='255.255.255.0'
uci set network.lan.proto='static'
uci add_list network.lan.dns='8.8.8.8'
uci add_list network.lan.dns='8.8.8.4'
uci commit
/etc/init.d/network restart

I set the network with the above commands, it succeeds and I can ping to 8.8.8.8
but when I check file /etc/config/network. It still not update new configurations.

config interface 'lan'
        option ifname 'eth0'
        option force_link '1'
        option macaddr '9c:65:f9:4b:8c:f9'
        option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '0'

And when I use curl to download files. It appeared error
curl: (6) Couldn't resolve host
Does anyone know how to fix this?
Thanks

Is the filesystem writeable?
df -h; mount; ls -la /etc/config/

yes, it is writeable. Cuz I can config network file with vi. But I want to use UCI to make automation script

What happens if you issue:
uci commit network

and then check the network file?

1 Like

ubus call system board; uci show network.lan; uci set network.lan.ip6hint='aa'; uci show network.lan; uci commit; ifup lan; uci export network

Hi, I have solved the problem: specify

uci commit network

instead of commit

uci set network.lan.ipaddr='192.168.19.191'
uci set network.lan.gateway='192.168.19.1'
uci set network.lan.netmask='255.255.255.0'
uci set network.lan.proto='static'
uci add_list network.lan.dns='8.8.8.8'
uci add_list network.lan.dns='8.8.8.4'
uci commit network
/etc/init.d/network reload

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.