I've been searching I haven't found an answer. Maybe I'm not looking the right place or what I want can't be done.
I have compiled a firmware, for a TPLink TL-WR840N v4.0, and this firmware I use in many devices. I a /etc/config/network file with my custom config, and I want to include an auto-generated ula_prefix.
I firstly installed a firmware I've downloaded from OpenWRT site, then copied config files from the router to edit and create my I custom configs. The problem is that all routers will have the same ula_prefix, and I can't find the answer to make it auto-generated. If I omit the line "option ula_prefix", it will be disabled.
Is there a way to make it auto-generated for each router I install my custom firmware?
/etc/config/network is an all or nothing deal, it's only touched/ modified if it's missing alltogether.
You will have to write your own uci-defaults script to accomplish what you're looking for.
https://openwrt.org/docs/guide-developer/uci-defaults for more details. If you're pre-populating
/etc/config/network in your ROM, then something as simple as generating a random prefix and using a
sed -i replacement would likely do it. There are several useful script functions available in
I believe that the default base-files package includes a uci-defaults script (12_network-generate-ula) that does this.
I'm not a programmer so I may be completely misreading the code , but it looks to me like setting network.globals.ula_prefix to 'auto' might provide the behaviour you're looking for?
Ship the configuration with
option ula_prefix auto. The
auto value will get replaced with a randomly generated prefix on first boot.
Thank you everyone for reply.
The simplest way is really to set "option ula_prefix auto" on /etc/config/network file. I have tried it but I didn't payed attemption to the fact that the script that will auto-generate it will run only once, after the first boot. So I was only rebooting the router expecting it would auto-generate without performing a factory-reset. After changing network fila with "option ula_prefix auto" and recompiling the firmware, and flashing it, then it works. Each time I perform a factory-reset it will generate a new random ula_prefix.
If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.