[OpenWrt-Devel] How am I supposed to change settings in /etc/config/network of default root file system of OpenWRT?

Jeonghum Joh oosaprogrammer at gmail.com
Tue May 19 07:23:27 EDT 2020


Hello Magnus Kroken and Adrianschmutzler,

Thank you! I made it work!

Magnus Kroken's second method works!

Thank you!

But I have another question :

  config zone
          option name       wan
          list   network          'wan'
          list   network          'wan6'
+        list   network          'wwan'
          option input            REJECT
          option output           ACCEPT
          option forward          REJECT

Above is part of /etc/config/firewall.
And as you see, I'd like to add new interface wwan into zone wan.
How can I write uci command script for this?

Thank you very much!
Jeonghum

2020년 5월 19일 (화) 오후 6:38, Magnus Kroken <mkroken at gmail.com>님이 작성:

> Hi
>
> On 19.05.2020 08:30, Jeonghum Joh wrote:
>  > config interface 'wwan'
> >          option ifname 'usb0'
> >          option proto 'dhcp'
> >
> > So I added something like below to
> > package/base-files/files/etc/board.d/99-default_network :
> >
> >    ucidef_set_interface_lan 'eth0'
> >    [ -d /sys/class/net/eth1 ] && ucidef_set_interface_wan 'eth1'
> > +[ -d /sys/class/net/usb0 ] && ucidef_set_interface_wan 'usb0'
> >
> > But this didn't resolve my problem.
> >
> > I think I can just make some commands into startup script.
> > Isn't there more grace approach for me to automatically add usb0
> > interface into /etc/config/network?
>
> As already suggested, use the files/ directory to include files.
>
> $ cd openwrt # change to the root of your OpenWrt build environment
> $ mkdir -p files/etc/uci-defaults
> $ mkdir -p files/etc/config
>
> Now you have two options.
>
> 1. Put your complete working /etc/config/network file in the files/
> tree, so it resides at files/etc/config/network.
>
> 2. Write a script with the UCI commands needed to change your config,
> and put it in files/etc/uci-defaults. I name mine e.g.
> zzz_33_device_config, so that they are executed as late as possible.
>
> The commands you would need for option 2 is probably:
>
> uci -q set network.wwan=interface
> uci -q set network.wwan.proto='dhcp'
> uci -q set network.wwan.ifname='usb0'
> exit 0
>
> This is very simple, you may want to script checks to ensure the script
> is running on correct device (e.g. by checking for a MAC address), and
> if the usb0 device exists.
>
> Regards
> Magnus Kroken
>
> > Thank you in advance.
> > Jeonghum
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20200519/87495b4f/attachment.htm>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list