Jon Brookes
2025-01-19
I Just got delivery of the new OpenWrt One device this weekend so wanted to put it through its paces. Initially I was eager to esablsh how to re-install this new device to factory defaults and I ended up finding and commenting in this reddit post
There after I wanted to know, how if at all possible, its Network configuration for WiFi could be set up using just the command line.
To cut a long story short, here are the UCI commands I used to set up the 2nd Wifi, the faster one of the 2. This can be changed round to configure also the first by just changing the numbering accrodingly from radio1
:
uci set wireless.radio1.country=XX
uci set wireless.radio1.cell_density=0
uci set wireless.default_radio1.ssid='<name of your wifi>'
uci set wireless.default_radio1.encryption='psk2'
uci set wireless.default_radio1.key='<very secure passphrase or key>'
uci set wireless.radio1.disabled=0
uci commit wireless
wifi reload
Where country is your country code making certain to get this right as it is regulartory and compliant with the coutnry of origin.
and then wait a few minutes for the service to restart and sort itself out. Mine took aound 30 seconds, not long but it was not instant.
This is the same as this could be set up using Enabling a Wi-Fi access point on OpenWrt from the OpenWrt quick start where it walks through this setup with the web console called Luci.
However, getting to know how to do this with uci is I believe a worth while investment as this enables automation that can be repeated on other systems or as a recovery tool or both.
Any which way, you have something that is closer to configuration as code and that can’t be a bad thing as logging screen shots into Git is not something that will guaruntee a good time when it comes to reviewing changes over time to your infra.
Getting to this point is not straight forward, so here are my tips for anyone getting started on this path :
Ironically, I would say, use the Luci web interface initially however, make small, simple changes that you then quickly take a look at the files saved to /etc/config
of the OpenWrt system. The one I was particularly interested in for the above was the one called wireless
. It gave me some pretty good clues as to what needed to be set with the above comands.
Next, running uci show | awk -F'.' '{print $1}' | sort | uniq
gives a list of top level objects if you will that can can be set using uce
:
uci show | awk -F'.' '{print $1}' | sort | uniq
dhcp
dropbear
firewall
luci
network
rpcd
system
ubihealthd
ubootenv
uhttpd
wireless
from this, I just ran uci show wireless
to show all settings current to wireless devices.
getting individual settings with uci is as simple as
uci show wireless.radio1.disabled
wireless.radio1.disabled='0'
which confirms the above set commands have had an effect.
OpenWrt is an operating system that is aimed at devices and as such is a bit like other network appliances that need for changes to be committed before they are persisted. This means that the filesystem is not being written to as you set things. For that a uci commit
command needs to be used to write these changes out of memory and into its persisted filesystem.
Then, some things will need restarted, as in the above wifi reload
which is similar / same to how Linux and other Unixes work where a process needs to be restarted in order for the changes to be picked up.
uci
is in my view ‘the way’ to centrally configure OpenWrt devices and to have a consistent, reliable and maintainable method of configuration for most aspects of its administraiton.
Even firewall rules are configured using uci
but that would be the content of a futher missive as this one is gone on long enough just now.
I’m so far pleased to find the OpenWrt One device a convincing, solid looking and feeling router and firewall that could take the world by storm.
Its open architecture, repair-ability and long term maintainability makes not just practical sense but also sense for the environment as it has, hopefully, a longer life than otherwise disposable, proprietary and often out of date and insecure closed source rivals.