How to change the defaults for "Reset to Default"

I am going to flash OpenWrt to a router, and give it to my brother to use at his home.

By default, when doing a reset, OpenWrt will have Wifi disabled, lan 192.168.1.1, etc.

I would like to have a specific configuration pre-configured for each router (he will be using 3 - 1 as main router and 2 as dump AP - with LAN connection if possible, and Mesh if not), so that when doing a reset to default, the original configuration will be used.

And will that set of "defaults" survive across Attended SysUpgrades?

AFAIK you need to compile your own image with customized configuration files to do that. See the Wiki: https://openwrt.org/docs/guide-developer/uci-defaults

I can't comment on the other questions since I never needed that.

1 Like

If you don’t already have a build environment set up, your best bet would be to use the ImageBuilder. https://openwrt.org/docs/guide-user/additional-software/imagebuilder#using_the_image_builder

Specifically, follow https://openwrt.org/docs/guide-user/additional-software/imagebuilder#custom_files

Place your custom configs in the files folder. ie place your custom network, firewall, dhcp configs in files/etc/config/network . . .

Yes.

2 Likes

Wouldn't having persistent custom default configs mean that auc is not usable after that and future upgrades would each need to be a custom build with installation via sysupgrade pointing to the custom image, especially on squashfs based images?

1 Like

Not according to the wiki https://openwrt.org/docs/guide-user/installation/attended.sysupgrade#from_luci_web_page

  • If you wish to keep settings, check the box. Otherwise, settings will be erased and set to factory default.

  • Click Install Sysupgrade and the router will download the new image, flash it, and reboot.

  • You'll be running the new firmware, with all your packages and settings intact.

1 Like

It is my understanding that what you are referring to relates to keeping the active settings only. Installing or upgrading to a normal sysupgrade would install the standard "default" config so any issuing of the firstboot command ('Reset to defaults' in Luci) would no longer use his custom 'default' config as installed by your recommended method.

I would think that in order to achieve the goal of the OP, a custom build for every future upgrade would be needed.

EDIT: I take "... so that when doing a reset to default, the original configuration will be used." to mean that he wants his custom config to be applied and not the OpenWrt standard default config from /rom/etc/config/.

1 Like

That is true.

Having your personal settings included in the image as the reset-proof defaults requires a personal image compilation with "custom files" (with imagebuilder or full buildroot) or directly modifying the original source code (with the full buildroot).

  • supplying the modified config files as custom files is the easiest method,
  • including uci-defaults scripts that modify settings as custom files would be slightly harder
  • modifying sources is much harder (and required full buildroot)

(Attendedsysupgrade knows nothing about the current settings, but as it uses the normal sysupgrade for flashing the generated image, it naturally allows keeping the current settings. But the current settings are not included in the generated image itself, as they are provided as an additional backup file to be flashed. And reset would quite normally lead to the original normal defaults.)

2 Likes

Hi

i am using following approach for this
reset your router to defaults
install additional packages
setup everything as you wish
when you finish, copy with SCP files from router /etc/config to your PC
setup your build environment (ex on Linux)
copy your files into /home/user/openwrt/files
openwrt is folder where you git clone
make menuconfig
select all packages which you are installed from Luci
compile your custom bulid
flash to router

this way, factory reset will always be a good working premade config
packages are already installed

... similar things could be made with online firmware selector +additional packages + "uci defaults"

1 Like