Skip to content

Custom config files

Eric Sauvageau edited this page Jun 28, 2024 · 32 revisions

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

Enabling support for custom configs

This functionality is disabled by default. To enable it, go to Administration -> System, then enable it under the JFFS section.

If you accidentally lock yourself out of your router due to a bugged custom config, a factory default reset will let you regain access to your router

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:

  • adisk.service
  • afpd.service
  • avahi-daemon.conf
  • cake-qos.conf (only cake-qos.conf.add supported)
  • dhcp6s.conf
  • dnsmasq.conf
  • dnsmasq-INDEX.conf (for SDN, only .add is supported, INDEX = SDN index number)
  • 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)
  • igmpproxy.conf
  • inadyn.conf
  • minidlna.conf
  • mt-daap.service
  • nanorc (no .add support) - as documented here (External page). 384.3 or newer.
  • pptpd.conf
  • profile (shell profile, only profile.add supported)
  • smb.conf
  • snmpd.conf
  • stubby.yml (only stubby.yml.add supported)
  • stubby-INDEX.yml (for SDN, only .add is supported, INDEX = SDN index number)
  • torrc
  • vsftpd.conf
  • upnp (for miniupnpd)
  • wgclient%d (%d = unit number)
  • wgserver
  • wgserver_peer (peer config file generated to connect to the local server)

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. You can also use these scripts for any other type of action that you wish to execute just before the daemon gets started (for instance, modifying a firewall rule, logging some sort of notification, etc...)

Postconf scripts must be stored in /jffs/scripts/ . The path/filename of the target config file is passed as argument to the postconf script. Please also read the general notes on creating scripts here.

The list of available postconf scripts is:

  • adisk.postconf (Time Machine)
  • afpd.postconf (Time Machine)
  • avahi-daemon.postconf (Time Machine)
  • dhcp6s.postconf
  • dnsmasq.postconf
  • dnsmasq-sdn.postconf (the SDN index number is passed as second argument, 1 is the first instance)
  • exports.postconf
  • fstab.postconf
  • group.postconf
  • gshadow.postconf
  • hosts.postconf
  • igmpproxy.postconf
  • inadyn.postconf
  • ipsec.postconf
  • minidlna.postconf
  • mt-daap.postconf
  • openvpnclient1.postconf (1 through 5)
  • openvpnserver1.postconf (1 or 2)
  • passwd.postconf
  • pptpd.postconf
  • shadow.postconf
  • smb.postconf
  • snmpd.postconf
  • strongswan.postconf
  • stubby.postconf
  • stubby-sdn.postconf (the SDN index number is passed as second argument, 1 is the first instance)
  • torrc.postconf
  • upnp.postconf
  • vsftpd.postconf
  • wgclient%d.postconf (%d = unit number, between 1 and 5)
  • wgserver.postconf
  • wgserver_peer.postconf (for generation of the remote peer config file)

To make things easier for novice users who don't want to learn the arcane details of using "sed", a script providing support functions is available. The following dnsmasq.postconf script demonstrates how to modify the maximum number of leases in the dnsmasq configuration:

#!/bin/sh
CONFIG=$1
source /usr/sbin/helper.sh

pc_replace "dhcp-lease-max=253" "dhcp-lease-max=100" $CONFIG

The following functions are currently available through helper.sh:

pc_replace "original string" "new string" "config filename"
pc_insert "string to locate" "string to insert after" "config filename"
pc_append "string to append" "config filename"
pc_delete "string within line to delete" "config filename"

Note that postconf 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.

Clone this wiki locally