I've tested the new version of the Dnsmasq Custom Options feature created by @systemcrash and it seems to be working properly.
The new feature adds a new configurable field with uci for dnsmasq called extraconftext
that can be used to add any supported option by the current dnsmasq version in OpenWrt. Technically, most of these features are now configurable via uci: https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html
If you want try and test the commit, these are the steps:
-
Make a backup of your current configuration via Luci > System > Backup > Generate archive
-
Create 2 new folders on your Desktop called dnsmasq-backup
and dnsmasq-new
(Terminal on macOS is used for this example, but the same can be applied to other platforms)
-
Save a backup of your current dnsmasq file from OpenWrt by using this command in Terminal:
scp -O root@192.168.1.1:/etc/init.d/dnsmasq ~/Desktop/dnsmasq-backup/
-
Download the latest dnsmasq.init file from https://raw.githubusercontent.com/systemcrash/openwrt/dnsmasq_filter_rr_v2/package/network/services/dnsmasq/files/dnsmasq.init and save it to ~/Desktop/dnsmasq-new/dnsmasq
-
Make the new dnsmasq file executable with this command:
chmod +x ~/Desktop/dnsmasq-new/dnsmasq
-
Upload the new dnsmasq file to OpenWrt:
scp -O ~/Desktop/dnsmasq-new/dnsmasq root@192.168.1.1:/etc/init.d/
-
Log into OpenWrt using SSH, and use uci to setup a custom configuration:
uci set dhcp.@dnsmasq[0].extraconftext='address=/example.com/0.0.0.0'
uci commit dhcp
- Restart the new dnsmasq file to apply the new configuration:
/etc/init.d/dnsmasq restart
That's it!
You can use any valid dnsmasq option in the extraconftext
configuration. In the example above, we used address=/example.com/0.0.0.0
You can also add multiple lines separated by \n
. For example, to add
address=/example.com/0.0.0.0
server=1.1.1.1
use these commands in OpenWrt via SSH:
uci set dhcp.@dnsmasq[0].extraconftext='address=/example.com/0.0.0.0\nserver=1.1.1.1''
uci commit dhcp
/etc/init.d/dnsmasq restart
What this does is it will create a new dnsmasq.conf file in /tmp/dnsmasq.cfg01411c.d/extraconfig.conf
with the specified options and will read that file with the rest of the dnsmasq configurations on initialization. The folder is created based on the name of your dnsmasq config name.
Please note that as this feature can accept any dnsmasq option, it's up to you to make sure what you add to it doesn't conflict with other configurations.
If you can, try out the new dnsmasq.init file using the guide above, check if it works properly, and review it or add suggestions on its Pull Request: https://github.com/openwrt/openwrt/pull/14975
To revert back to your original dnsmasq file, you can use the backup file from the guide above:
scp -O ~/Desktop/dnsmasq-backup/dnsmasq root@192.168.4.6:/etc/init.d/
If you use a squashfs image for OpenWrt, you can also delete the modified file from the overlay and use the original dnsmasq file from the squashfs image:
cd /overlay/upper/etc/init.d/
rm -rf dnsmasq
mount -o remount /
/etc/init.d/dnsmasq restart