Skip to content

Custom config files

Eric Sauvageau edited this page Jan 23, 2014 · 32 revisions

The services executed by the router such as minidlna or dnsmasq relies on dynamically-generated config files. There are various methods through which you can interact with these config scripts to customize them.

Replacing or appending content to config files

You can append content to various configuration files that are created by the firmware, or even completely replace them with custom config files you have created. Those config override files must be stored in /jffs/configs/. To have a config file appended to the one created by the firmware, simply add ".add" at the end of the filename taken from the list below. For example:

/jffs/configs/dnsmasq.conf.add

will be added at the end of the dnsmasq configuration file that is created by the firmware, while:

/jffs/configs/dnsmasq.conf

would completely replace it.

Note that replacing a config file with your own implies that you properly fill in all the fields usually dynamically created by the firmware. Since some of these entries require dynamic parameters, you might be better using the postconf scripts added in 374.36 (see the postconf scripts section below).

The list of available config overrides:

  • dhcp6s.conf
  • dnsmasq.conf
  • exports (only exports.add supported)
  • fstab (only fstab supported, remember to create mount point through init-start first if it doesn't exist!)
  • group, gshadow, passwd, shadow (only .add versions supported)
  • hosts (for /etc/hosts)
  • minidlna.conf
  • pptpd.conf
  • profile (shell profile, only profile.add suypported)
  • radvd.conf
  • smb.conf
  • vsftpd.conf
  • upnp (for miniupnpd)

Also, you can put your own OpenVPN ccd files in the following directories:

  /jffs/configs/openvpn/ccd1/
  /jffs/configs/openvpn/ccd2/

The content of these will be copied to their respective server instance's ccd directory when the server is started.

Postconf scripts

A lot of the configuration scripts used by the router services (such as dnsmasq) are dynamically generated by the firmware. This makes it hard for advanced users to apply modifications to these, short of entirely replacing the config file.

Postconf scripts are the solution to that. Those scripts are executed after the router has generated a configuration script, but before the related service gets started. This means you can use those scripts to manipulate the configuration script, using tools such as "sed" for example.

Postconf scripts must be stored in /jffs/scripts/ .The path/filename of the target config file is passed as argument to the postconf script.

The list of available postconf scripts is:

  • dhcp6s.postconf
  • dnsmasq.postconf
  • exports.postconf
  • fstab.postconf
  • group.postconf
  • gshadow.postconf
  • hosts.postconf
  • minidlna.postconf
  • openvpnclient1.postconf (and openvpnclient2.postconf)
  • openvpnserver1.postconf (and openvpnserver2.postconf)
  • passwd.postconf
  • pptpd.postconf
  • radvd.postconf
  • shadow.postconf
  • smb.postconf
  • upnp.postconf
  • vsftpd.postconf

Here is a simple dnsmasq.postconf script that demonstrates how to modify the maximum number of leases set in the dnsmasq configuration:

#!/bin/sh
CONFIG=$1

sed "s/dhcp-lease-max=253/dhcp-lease-max=100/" -i $CONFIG

Note that these scripts are blocking the firmware while they run, to ensure the service only gets started once the script is done. Make sure those scripts do exit properly, or the router will be stuck during boot, requiring a factory default reset to recover it. Test them prior to rebooting the router with them in place.

Clone this wiki locally