interfaces: prevent DHCP from installing nameservers when not allowed

This was refactored previously and all the logic should live outside
dhclient-script but it seems it's only loosely handled over there.
For now put a check back in the old way and rework this later correctly
from the system.inc point of view: we do want to register nameserver
and searchdomain in the cache files, but should not add a route if
those are not required.  It would be helpful to show them in the overview
regardless (as for DNS servers) but with a hint that they are not being
used.

PR: https://forum.opnsense.org/index.php?topic=26765.0
This commit is contained in:
Franco Fichtner 2022-02-05 08:16:43 +01:00
parent 4dfe599241
commit 02dc1ebd93

View File

@ -223,6 +223,12 @@ add_new_resolv_conf() {
fi
rm -f /tmp/${interface}_nameserver
rm -f /tmp/${interface}_searchdomain
if [ "$(pluginctl -g system.dnsallowoverride)" != "1" ]; then
# prevent installing DNS information when not allowed
return 0
fi
if [ -n "$new_domain_name_servers" ]; then
for nameserver in $new_domain_name_servers; do
@ -234,8 +240,6 @@ add_new_resolv_conf() {
done
fi
rm -f /tmp/${interface}_searchdomain
if [ -n "$new_domain_name" ]; then
echo $new_domain_name > /tmp/${interface}_searchdomain
fi