OpenWrt Forum Archive

Topic: what does "uci commit" do?

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

What does "uci commit network" do?

Let's say, I booted OpenWrt with network-configuration of pppoe and now changed it with vim to  dhcp in /etc/config/network.

Will "uci commit network" will start udhcpc and try to get an IP via DHCP?

Would "uci commit firewall" do the same as "sh firewall.user"?



The gnome "Network manager Applet" is already driving me crazy because it doesn't behave like I would expect it to.

That page doesn't really describe what the 'commit' exactly does; it only explains to do so after changing configuration. Now what I also would like to know is what exactly happens under water there.

Ah ok, so you need a "/etc/init.d/uhttpd restart" without it, it won't work.

So uci commit simply writes stuff to the disk/flash, but does NOT execute programs?

I my case, I would have needed to execute "udhcpc" to get things working again. But how would I do that?

uci commit is superfluous, I can edit the files myself, what I need is a command to execute things immediately.

The commit operation is not superfluous, its needed for programmatic changes to uci files. All "uci set", "uci add", "uci rename" and "uci delete" commands are staged in tmp and written to flash at once with "uci commit".
This obviously does not apply to people using text editors, but to scripts, guis and other programs working with uci files.

You aren't intended to edit the files in /etc/config directly, though there is obviously nothing preventing you from doing so.

However, using UCI to modify your configuration is preferred as it could avoid syntax errors that may be difficult to diagnose.

If I set my WAN interface from pppoe to dhcp using UCI, the command is as follows:

uci set network.wan.proto=dhcp

If you cat /etc/config/network, you'll notice that the file itself still says pppoe. However:

uci get network.wan.proto
dhcp

Any processes which read the value will receive "dhcp" and not "pppoe". If you want this change to be permanent, you call "uci commit" and now the change is written to the file.

You should pretty much never need to start a dhcp client manually. Network setup, among most other router functions, are handled in init scripts located in /etc/init.d

After changing your network configuration, you'll want to either:

ifup wan

or

/etc/init.d/network restart

Please read the documentation. It will save you lots of time and trouble.

aport wrote:

You aren't intended to edit the files in /etc/config directly, though there is obviously nothing preventing you from doing so.

However, using UCI to modify your configuration is preferred as it could avoid syntax errors that may be difficult to diagnose.

totally wrong. Text based config files is the human readable interface and is the normal way for people to change settings. The uci way is the machine interface because it is much easier to use commands rather then edit text files on the fly.

aport wrote:

You aren't intended to edit the files in /etc/config directly, though there is obviously nothing preventing you from doing so.

Oh you would just love from preventing me doing so, wouldn't you?

After changing your network configuration, you'll want to either:

ifup wan

The name of my WAN-interface is "eth0.2" and I know it and I even brought her breakfast :-P

/etc/init.d/network restart

This would probably kick me out of ssh. The "ifup/ifdown "individual interface"" is the real deal here ;-)

You don't happen to know, why "ifup/ifdown is bitchin' around on debian, do you? I bet it's because of some network-manager, the whore!

Back in the day, you would edit, /etc/network/interfaces and then do a ifdow/ifup, and then things worked. They don't any more :-(

Thx for the help!

flux wrote:
aport wrote:

You aren't intended to edit the files in /etc/config directly, though there is obviously nothing preventing you from doing so.

However, using UCI to modify your configuration is preferred as it could avoid syntax errors that may be difficult to diagnose.

totally wrong. Text based config files is the human readable interface and is the normal way for people to change settings. The uci way is the machine interface because it is much easier to use commands rather then edit text files on the fly.

Yes sir! I hope this is the reason, why we bother to document them. So people use them.

scruffy wrote:

The name of my WAN-interface is "eth0.2" and I know it and I even brought her breakfast :-P

As far as ifup/ifdown *on OpenWrt* is concerned, the name is "wan" and not "eth0.2" which would not even be a valid uci section identifier.

scruffy wrote:

Oh you would just love from preventing me doing so, wouldn't you?

I really don't care. IMO people who edit UCI files using vim or nano are either uninformed or masochistic smile

The name of my WAN-interface is "eth0.2" and I know it and I even brought her breakfast :-P

Your WAN interface is named "wan" unless you changed it. Network scripts grab the interface name from the UCI section, in this case, wan. "eth0.2" is the "iface" as you'll see:

uci get network.wan.iface
eth0.2

You don't happen to know, why "ifup/ifdown is bitchin' around on debian, do you? I bet it's because of some network-manager, the whore!

Back in the day, you would edit, /etc/network/interfaces and then do a ifdow/ifup, and then things worked. They don't any more :-(

Thx for the help!

All I know about NetworkManager is that it seems to think it knows what I want, and usually it is wrong.

aport wrote:
scruffy wrote:

Oh you would just love from preventing me doing so, wouldn't you?

I really don't care. IMO people who edit UCI files using vim or nano are either uninformed or masochistic smile

1. I have to type less.
2. I also see the current configuration in front of me.
3. I can merely comment things out, and next time uncomment them, comment the other config out, ..., you get the point.

I also don't have to memorize the uci-syntax. It's not complicated, but why bother.

The name of my WAN-interface is "eth0.2" and I know it and I even brought her breakfast :-P

Your WAN interface is named "wan" unless you changed it.

I did change it, to make it more distinguishable from wlan and lan. ;-)

However, like jow pointed out, the ifup/down-scripts on openwrt, look for uci-names. But if you write own scripts, for firewall/traffic shaping, you have to use the real names again. pppoe instead of wan. I think.

That would be my next question: why does OpenWrt name it's interfaces?


You don't happen to know, why "ifup/ifdown is bitchin' around on debian, do you? I bet it's because of some network-manager, the whore!

Back in the day, you would edit, /etc/network/interfaces and then do a ifdow/ifup, and then things worked. They don't any more :-(

Thx for the help!

All I know about NetworkManager is that it seems to think it knows what I want, and usually it is wrong.

Me too! Me too!  Let us gang up and slap his face really really hard.

scruffy wrote:

1. I have to type less.
2. I also see the current configuration in front of me.
3. I can merely comment things out, and next time uncomment them, comment the other config out, ..., you get the point.

I also don't have to memorize the uci-syntax. It's not complicated, but why bother.

Good points... I'm really not a uci "purist" as I might be expressing. I fire up VIM pretty often for config files, but I definitely use the uci tool more.
Perhaps if I had said "required" instead of "intended" then everyone could get off my back smile

That would be my next question: why does OpenWrt name it's interfaces?

There are many good reasons, most importantly it's a simple abstraction to hide minor details from other portions of the system. For example, the firewall is configured with network interface names (via UCI) instead of physical hardware device names. This allows, for example, for me to add or remove hardware devices (for instance bridging) from an interface, without having to modify anything else on the system... it all works great.

This also has advantages when you take into account the broad cross-platform nature of OpenWrt. Different boards have different hardware device names, but system services like the firewall don't really need to care about them. All the configuration is done in /etc/config/network.

(Last edited by aport on 13 Jun 2011, 18:44)

That would be my next question: why does OpenWrt name it's interfaces?

To make lookups easier. Especially when managing multiple PPPoE or tunnel links it good to be able to derive the network name from the interface.
ppp0 ... ppp9 does not really cut it, and constantly changing interface names are annyoing as well. As far as iptables is concerned, the "ppp+" wildcard syntax still works.

Oh and to translate network to interface names:

WAN=$(uci -P/var/state get network.wan.ifname)
iptables -I INPUT -i $WAN ...

Uh, now that is support ;-) Appreciate it!

Now where to put it (I wish my girl-friend would ask .., ah, never mind):

http://wiki.openwrt.org/doc/uci
http://wiki.openwrt.org/doc/uci/network
http://wiki.openwrt.org/doc/techref/uci
http://wiki.openwrt.org/doc/networking/ … interfaces

On the one hand, you don't want to overwhelm the beginner with (for him) useless and confusing information, on the other hand you do want to give advanced users/programers a good quick overview.

The discussion might have continued from here.