Why explicitly specify the default value for an option?

Hello,
For the sake of readability, I am reviewing the configuration of my dnsmasq instance. It turns out that many options are explicitly set to their default values (according to the official OpenWrt documentation) in the base configuration file.

According to the documentation, this config

config dnsmasq
	option domainneeded	1
	option boguspriv	1
	option filterwin2k	0  # enable for dial on demand
	option localise_queries	1
	option rebind_protection 1  # disable if upstream must serve RFC1918 addresses
	option rebind_localhost 1  # enable for RBL checking and similar services
	#list rebind_domain example.lan  # whitelist RFC1918 responses for domains
	option local	'/lan/'
	option domain	'lan'
	option expandhosts	1
	option nonegcache	0
	option cachesize	1000
	option authoritative	1
	option readethers	1
	option leasefile	'/tmp/dhcp.leases'
	option resolvfile	'/tmp/resolv.conf.d/resolv.conf.auto'
	#list server		'/mycompany.local/1.2.3.4'
	option nonwildcard	1 # bind to & keep track of interfaces
	#list interface		br-lan
	#list notinterface	lo
	#list bogusnxdomain     '64.94.110.11'
	option localservice	1  # disable to allow DNS requests from non-local subnets
	option ednspacket_max	1232
	option filter_aaaa	0
	option filter_a		0
	#list addnmount		/some/path # read-only mount path to expose it to dnsmasq

would be equivalent to this one.

config dnsmasq
	option local '/lan/'
	option domain 'lan'
	option cachesize '1000'
	option leasefile '/tmp/dhcp.leases'

Is there any reason why it would be a bad idea to replace the basic configuration with this shorter version?

Preinstalled config has some descriptions for people who edit those directly.

1 Like

That makes sense for part of the base config. But for example, why explicitly set domainneeded to its default value? Historical reason?

Probably it worked for some people back long time ago.

1 Like

I'd guess the idea is 1. to show the user which options exist, and 2. if the user wants to modify the values, having the options already in place reduces the chance of the user misspelling them.

4 Likes