OpenWRT Configuration Hacks [Part 1]

by kacang bawang

In this post I will talk about some configuration optimizations to OpenWRT 12.09 “Attitude Adjustment”. It is the first in a two part series (part 2). In this part we will deal with dropbear configuration.


Problem:
I organize my home network in 3 interfaces: WAN, LAN and WIFI. I would like to run an ssh server on the latter two. In stock installation it is accomplished like this:

This works, but, it results in two instances of dropbear running at all times, one for each interface.

However, dropbear allows the following commandline when called manually:

Only one copy is running and it is listening on both interfaces where it is wanted.
How do we achieve this from the config files?

Solution:
We will modify /etc/init.d/dropbear, the intermediate layer that takes configuration files as input and starts the dropbear process with the desired options. The most logical solution would be to modify things in such a way that the following config would be accepted:

Alas, “exploding” the Interface string is a non-trivial task. But we have another option. OpenWRT configs have an alternative to the option called list. It’s basically the same thing, but can be iterated. Thus, our config becomes:

To parse this config, let’s modify /etc/init.d/dropbear like this.

Now restart dropbear. Both files before and after can be found here. (For the “before” go to file history).