[Commotion-dev] Using UCI to define static routes on nodes

Will Hawkins hawkinsw at opentechinstitute.org
Wed Jul 3 18:51:46 UTC 2013


I'm sure that most everyone here knows about this, but it bit me
yesterday and I wanted to post it for posterity (is that redundant?):

OpenWRT users can define static routes on nodes through UCI. In the
/etc/config/network file, it looks something like this:

config route '<optional route name>'
	option interface '<name of interface>'
	option target '<target as dotted quad>'
	option netmask '<netmask in dotted quad>'
	option gateway '<gateway in dotted quad>'

It can also be done through the web interface. Incredibly useful. Here's
where I flubbed it:

Let's say that my plug interface (eth0) is 172.16.0.0/16 but I want to
use 192.168.1.1 as my gateway for a default route through the plug.
Using 'ip', I could do this like:

ip route add 0.0.0.0/0 via 192.168.1.1 dev eth0

However, this type of "via" route is not possible using the UCI
configuration. Before applying the static routes from the config, UCI
checks to see if the gateway is in the interface's network range. There
is probably a way around this, but I could not figure it out. Also, as
far as I can tell, there's very little information spit out in the debug
files to tell you about this.

Please, PLEASE, let me know if you've worked through this issue before
and successfully solved it. Otherwise, it's just something to keep in mind!

Will


More information about the Commotion-dev mailing list