How to set values with UCI instead of LuCI (solved)

My goal is to set entry's with the same naming scheme with uci like it is done via LuCI.
This is an example for wireguard.

Of course I have read the doc's. But they are very unclear in this point.
Just to confuse beginners since the samples use other naming conventions then then web GUI ...

Global entries set by LuCI:

network.wg_srv0.addresses='' 'fdf1::1/64'

Peer 1 & 2 set by luci

network.@wireguard_wg_srv0[0]=wireguard_wg_srv0 network.@wireguard_wg_srv0[0].description='Peer1' network.@wireguard_wg_srv0[0].public_key='hLIRbZTClIDMEmjmdZkN3tyNRvOpcBV4crapB3OjcXg=' network.@wireguard_wg_srv0[0].allowed_ips='' network.@wireguard_wg_srv0[1]=wireguard_wg_srv0 network.@wireguard_wg_srv0[1].description='Peer2' network.@wireguard_wg_srv0[1].public_key='hLIRbZTClIDMEmjmdZkN3tyNRvOpcBV4crapB3OjcXg=' network.@wireguard_wg_srv0[1].allowed_ips=''

If the values are set via LuCI, I can change them with uci afterwards.

# uci set network.@wireguard_wg_srv0[0].allowed_ips=""

I'm able to set the global entries by uci instead of LuCI. No problem so far.

# uci set network.wg_srv0="interface"
# uci set network.wg_srv0.proto="wireguard"
# uci set network.wg_srv0.private_key="mJBT9SSpC8+1J7te7iWifzbJ1RCSwCfuHLGbk+CwQEo="
# uci set network.wg_srv0.listen_port="12345"
# uci add_list network.wg_srv0.addresses=""
# uci add_list network.wg_srv0.addresses="fdf1::1/64"

But I dont understand to add a peer with uci.
Let's try to add the first entry. The first line seems to be ok, since I got not error message.
But the second line gives me an error. Why that?

# uci set network.@wireguard_wg_srv0[0]=wireguard_wg_srv0
# uci set network.@wireguard_wg_srv0[0].description='Peer1'
uci: Invalid argument

When looking for the entries I get only the global values. No peer entries.
The first added line is not there ...

# uci show network |grep wg
network.wg_srv0.addresses='' 'fdf1::1/64'

So my final question is: How to add the peer (list) entries in LuCI style with uci?


1 Like
# Unnamed section
uci add network wireguard_vpn
uci set network.@wireguard_vpn[-1].public_key="..."

# Named section
uci set network.wgpeer1="wireguard_vpn"
uci set network.wgpeer1.public_key="..."

Both ways are valid, see also: WireGuard multi-client

1 Like

I see the difference of the uci command's.
Did not realize that I have to add a network entry with different syntax first, when using the "unnamed" way like LuCI did.

Thank you very much for pushing me to the right way.


1 Like

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