OpenWrt Forum Archive

Topic: Default network configuration built into image?

The content of this topic has been archived on 31 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I'm looking for a good thread on this but havent found it yet.
What I would like to do is have some of the items that I normally set after each image update via web interface baked into my image.
For example, I want the LAN to not be "static" but dhcp.  This is easy to change via the web interface, but I want it set that way when I install the image or at least on first boot.

It would appear that the file
/etc/config/network is what gets changed when I make the corresponding change in the web ui.
I tried changing that file in trunk/packages/base-files/files/etc/config/network, but it didn't seem to work.

config 'interface' 'lan'
        option 'ifname' 'eth0'
        option 'type' 'bridge'
        option 'defaultroute' '0'
        option 'peerdns' '0'
        option 'proto' 'dhcp'

After building and installing my image, I was back to "static" and

Can someone please explain how etc/config/network is generated and suggest a way modify it during the build process?  Is NVRAM involved?
If I can't put the change in when the image is built, can I run a script just after boot to make the changes?
I am using the WRT160NL with the  r22992 version of  OpenWRT.

Thank you.

While not directly answering you question, why don't you use "sysupgrade" or upgrade through LuCI? Then your settings will be kept when upgrading with a new image, and you only need to set it on the very first install.


The correct way to predeploy settings is the files/ directory.
Create trunk/files/etc/config/ and place the final network configuration file there.

In menuconfig, you can make changes to the network settings in Image Configuration (but I don't know about your "defaultroute" or "peerdns").

Alternatively, you can put your configuration in files/etc/config/network under where you have trunk installed.  Files within the "files" directory are copied into your build.  At least I think this will work--I haven't tried it with /etc/config/network.

Jow and lizby's approach will apply those files to all targets that you build. If  you are building more than 1 target but the files apply to only 1 of them, e.g. you are using OpenWRT on WRT54G and on Dockstar then an alternative is to create a files tree in the specific target directory. This would be target/linux/<platform>/base-files/..... , e.g. see target/linux/kirkwood as an example. If you are only building for 1 target then it doesn't matter which approach you use. Within a target you can apply to all profiles (in base-files/....) or to a specific profile (in base-files-<profilename>).


(Last edited by z80yyz on 26 Oct 2010, 22:46)

Thank you all for your ideas !
I haven't tried this one yet,  target/linux/<platform>/base-files/
But the suggestion of creating trunk/files/... DOES work.  YAY!

I'm left wondering why putting my change into trunk/package/base-files/files/etc/config did NOT work?  What is that dir for then?
I suppose I'm missing something about how the build process works.
If one of you gurus can explain that a bit, it would be nice. but my immediate issue is solved.

Thanks again.

Hi razor,
All is revealed when you look at the files in <topdir>/includes long enough :-) E.g. covers the suggestion I made (found this feature while investigating something else). There are probably more undocumented features waiting to be used.


Can you plase be a bit more specific in the the location of the trunk folder ?
I'm building OpenWRT for the APU2 that requires a bit of changes and i would lovo to put the deafualt configs already in.

i have a /home/username/Build_Folder/ppenwrt/ do i have to create a trunk folder
/home/username/Build_Folder/openwrt/trunk/ ?

The discussion might have continued from here.